0

I cannot login to a 16.04.4 LTS desktop installation after reboot via SSH unless I first login to the console locally (set to boot text only, not GUI).

According to this answer, network connections must be "system connections" in order for them to resolve (acquire an IP from DHCP) at boot time, prior to login. In this Ubuntu help tutorial, nothing is mentioned about initializing a connection prior to login, and this answer suggests simply modifying /etc/network/interfaces. I've tried this last answer, but I still can't ping the host until a local login is completed and the network connection is initialized.

Yes, I'm aware that my connections may not be named eth0. I've set them up as follows ...

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

#auto eth0
#iface eth0 inet dhcp

#_#auto enp0s25
#_#iface enp0s25 inet dhcp
#_#
#_#auto wlp2s0
#_#iface wlp2s0 inet dhcp

... where all of the #_# commented lines were uncommented, but that actually caused another issue, because then ubuntu made another set of similarly named interfaces and no networking worked at all...

How do I set the interfaces to properly initialize at boot instead of at login?

1 Answers1

0

First, your wireless will never connect unless you specify the SSID (router) you want to connect to, as well as supply the WPA2 password. Also, it will often be difficult to ssh to your computer that gets a dynamic, probably changing, IP address. Let’s create a proper interfaces file.

First, find the relevant interface name, if not wlp2s0, with the terminal command:

iwconfig

Second, I suggest a static, never changing, IP address. Pick one outside the range used by the DHCP server in the router. Here is an example: http://www.abyssunderground.co.uk/images/router/dhcp.gif

In this example, the DHCP range is from x.100 to x.159. Therefore, static IP addresses in the range of x.2 to x.99 or x.160 to x.253 are safe.

Ideally, you can check the DHCP range in the administrative pages of the router. If you are unable to do so, check the IP addresses of other connected devices in the network; phones, iPads, etc. You may see them all in a close range, say x.2 to x.10. Then you may probably be safe setting a static IP address far away, say x.200.

Now let’s set up /etc/network/interfaces. I suggest:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

#auto enp0s25
#iface enp0s25 inet dhcp

auto wlp2s0
iface wlp2s0 inet static
address 192.168.1.200
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1 8.8.8.8
wpa-ssid <your_network_name>
wpa-psk <your_secret_password>

Of course, substitute your exact details here. Restart the interface:

sudo ifdown wlp2s0 && sudo ifup -v wlp2s0

The -v for verbose should produce output that tells if there is a successful connection.

Test:

ping -c3 192.168.1.1
ping -c3 www.ubuntu.com

If you get ping returns, you are connected.

Reboot. Can you ssh into 192.168.1.200?

chili555
  • 61,330