Is it a DNS problem?
A good indication that you are facing a DNS problem on your machine is when you are connected to a network (meaning you still have an IP address assigned), but your internet connection suddenly stops working, and you are unable to ping DNS addresses like www.google.com:
ping www.google.com # unknown host
but you are still able to ping IP-addresses like 8.8.8.8:
ping 8.8.8.8 # works fine
This looks like you are not able to resolve DNS addresses any more – but you are still correctly connected to your network and to the internet.
What could cause this problem on Ubuntu?
Ubuntu uses NetworkManager, which in turn uses dnsmasq: a local DNS server running on your machine. As dnsmasq is started locally, redirecting DNS requests to the local address 127.0.0.1 would be fine in such a setup. You can see this being used by looking at your /etc/resolv.conf
file: if it shows the following line, a local DNS server is in use:
nameserver 127.0.0.1
However, with certain setups you might run into problem when using this way of resolving DNS addresses. This might be the case e.g. when you are using a different program in parallel to manage your connections, which is not cooperating with dnsmasq well.
What could be the solution?
An easy solution is to try if your machine works fine without using dnsmasq. In this case DNS with be resolved not using a local dnsmasq DNS server but using the DNS server advertised via DHCP. To disable dnsmasq with NetworkManager, comment out the dns=dnsmasq
line in /etc/NetworkManager/NetworkManager.conf
:
# dns=dnsmasq
This will prevent NetworkManager from starting a dnsmasq instance, hence will prevent it from locally resolving DNS lookups. DNS lookups will then be done using the DNS servers advertised to your machine from DHCP. You can check that this actually worked as follows: after a reboot (clears all possible cached DNS servers info on your machine) and connecting to a network you should see actual DNS servers showing up in /etc/resolv.conf
(with actual IP-addresses of course) in the place of the former 127.0.0.1
one:
nameserver x.x.x.x nameserver y.y.y.y nameserver z.z.z.z