I am running Ubuntu 18.04 on x64.
The machine has been up for a week or so, doing all the usual things it does, until today, I noticed that it had dropped off my local network. At the console, the "ifconfig" commands shows no IP address assigned to the eth0 device (Note: It's not actually eth0 anymore; they now give it a name which is a random collection of letters, but the idea is the same. I still think of it as eth0).
Now, as to the cause of this; I don't really care; I just assume some kind of software glitch. The question is: How to fix? I would imagein that the easiest solution is just to reboot, but I'd prefer to avoid that.
In the olden days, you could just unplug/replug the ethernet cable and it would fix itself. This always works under Windows, for example. It always worked in Linux, up until recently. I've noticed that current/later-day versions of Linux don't seem to fix themselves like they used to.
Further, on some version of Linux (but not Ubuntu, apparently), you could figure out which DHCP program (e.g., dhcpcd) they were using (it seems they keep changing it), usually by searching all running processes for a process containing the string "dh" and then you could figure out from the man pages how to get it running again. However, that method seems not to work in Ubuntu 18.04. In any case, I could not figure out which program was doing the dhcp'ing.
Anyway, I was able to get it working again by doing the following manual stuff (Note: This works because I happened to know the IP address that it should and did have before):
- ifconfig eth0-but-not really w.x.y.z
- route add default gw w.x.y.1
- edit /etc/resolv.conf - put in the nameserver (On my network, also w.x.y.1)
But, obviously, I'd like to know the right way to do it, to get the router to assign the IP address like it is supposed to.
Network restart
sudo ifconfig enxxxxxx down
# replace enxxxxxx with the correct network devicesudo ifconfig enxxxxxx up
Note: NetworkManager
Note:
dhclient
may need to be used. Seeman dhclient
.Network names (Optional)
It's not actually eth0 anymore; they now give it a name which is a random collection of letters, but the idea is the same. I still think of it as eth0.
It's actually not random. It identifies the slot/port of the device.
If you'd like the old/traditional (eth0, wlan0, etc.) network names again...
sudo -H gedit /etc/default/grub
Find:
Change it to:
Save the edits.
sudo update-grub
reboot
resolv.conf
Don't manually edit /etc/resolv.conf. It says so right in the file.
Edit your question and show me:
ls -al /etc/resolv.conf
cat /etc/resolv.conf