I periodically have issues with the DNS setup on my Ubuntu desktop. I finally decided to address this issue by forcing the DNS resolution to go through DNS servers I specify, rather than using the default of systemd-resolved. To do this, here are the steps:

$ sudo systemctl stop systemd-resolved.service
$ sudo systemctl disable systemd-resolved.service
$ sudo rm /etc/resolv.conf  # remove symlink
$ sudo -e /etc/resolv.conf  # see (1)
$ sudo -e /etc/NetworkManager/NetworkManager.conf  # see (2)

About (1), edit your resolv.conf file and set the DNS servers you want, for example:

# Control D

The final step (2) is to prevent NetworkManager from overwriting your resolv.conf file. In order to do that, add the following under the [main] section:


Reboot the computer and that should be it (and permanent).