No internet after upgrade from 16.04 to 18.04

Update 2: the bugreport was refused because I couldn't reproduce it on the already upgraded system and couldn't provide data for the developers.

Update 1: I reported the bug on launchpad. You can subscribe if you are involved: https://bugs.launchpad.net/ubuntu/+bug/1816530

the ORIGIN of the solution

if the /etc/resolv.conf is empty but you can ping 8.8.8.8

$ echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null

if the /etc/resolvconf/resolv.conf.d/head is empty then you have to repeat the command above after every restart except you do this:

$ echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolvconf/resolv.conf.d/head > /dev/null

then you have to restart the resolvconf and the networking

$ sudo systemctl enable resolvconf
$ sudo systemctl start resolvconf
$ sudo /etc/init.d/networking restart

I agree with some other folks here that the selected answer is probably not the best way to fix the issue:

When a file has a comment at its beginning that says

"DO NOT EDIT THIS FILE"

then there is probably a very good reason to, well, ... not edit that file! ;-)

And here is why, as well as a suggestion for a better (IMHO) solution:

a. the file /etc/resolv.conf, that you modified, will be overwritten at boot time, so your modification won't 'stick'.

b. the ip address (127.0.0.53) that was originally in there (before you modified it) is actually the address of a DNS stub resolver. It's there! You can ping it! it's running locally on your machine. What is a stub resolver? It takes your DNS queries and looks in its cache for a resolution! If it can't find any, it will reach out to a real DNS server (and then cache the result). So, if you overwrite the address of the stub resolver, you're going to miss out on this important caching function of the stub resolver!

The problem with this new resolver method in Ubuntu 18.04 is that the 'real' DNS server address was never set. So, if the stub resolver doesn't find your requested domain in its cache, it doesn't know what DNS server to query. (Hence your domain name based internet accesses no longer working). So all you have to do is configure the 'real' DNS server that this stub resolver must use. And you do this by editing (sudo!) /etc/systemd/resolved.conf

Simply add something like

DNS=8.8.8.8

to that file.

Then restart the network, or rather, reboot, so you can verify that you now have a solution that is persistent across reboots.

(What I haven't figured out yet, is why DHCP doesn't properly set the correct DNS server!)


Accepted answer did solve my problem. However, as everyone else stated, that is only until you reboot which I do daily with my machine. Typing 5 to 6 lines in the terminal every time I start the system up isn't something I would find amusing.

After digging on the internet I found a solution to permanently solve the problem. I rebooted 3 times afterward just to be sure, internet connection is there and I don't have to do anything.

Solution:

Start the terminal and type:

$ ifconfig

Now you gotta figure out which is your Ethernet interface. Mine is listed as eth1. Next type:

$sudo gedit /etc/network/interfaces

My file only had:

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

Now what you need to do is to add the following lines afterwards:

auto eth1
iface eth1 inet dhcp

Lastly, $ sudo ifup eth1, reboot and you're done. Don't forget to change eth1 with the name of your Ethernet interface.

Original answer