How to automatically get a DHCP nameserver after installing resolvconf on Ubuntu 18.04
I like to use resolvconf to allow me to make persistent modification to my resolv.conf file to do things like allow OpenVPN to resolve local DNS hostnames. In the past (mostly on Linux Mint machines I've simply installed resolvconf, and after doing so, no issues were induced related to how my machine connects to the internet, resolves hostnames, etc. Well on Ubuntu 18.04 after installing resolvconf my machine could no longer resolve hostnames (that is to say I could ping IP address but I couldn't ping host names or visit websites using their standard text based web address). The problem appears to be that the resolv.conf file was no longer getting a DNS nameserver from the DHCP server upon connecting to a network.
This thread helped me find the solution, which is fairly simple. Apparently the issue is unique to Ubuntu and was implemented by the Ubuntu team to fix some problems with multiple name servers present when using VPN and LAN connections simultaneously. Regardless, you can "fix" the issue caused by installing resolvconf on Ubuntu 18.04 (and likely other versions) by doing the following.
- Edit NetworkManager.conf by running
sudo nano /etc/NetworkManager/NetworkManager.conf
- Comment out the line that reads dns=dnsmasq or dns=default (or probably dns=<anything> by prepending it with a pound character (#). Your file should look something like this when it's done
[main] #dns=default plugins=ifupdown,keyfile [ifupdown] managed=false [device] wifi.scan-rand-mac-address=no
- Restart your computer and you should now be automatically getting a DNS nameserver from the DHCP server when you connect to a network. This means you should be able to ping hostnames and browse the internet as expected even with resolvconf installed.