Posted under » Ubuntu » Linux on 1 August 2017
Sometimes out of a sudden, your internet simply would not work. Most probably because your DNS settings are wrong. A simple delete of /etc/resolv.conf and a reboot should fix it.
However, if it still does not work, then force delete and edit the file like so.
$ rm -f /etc/resolv.conf $ vim /etc/resolv.conf
First is to remove the softlink /etc/resolv.conf, a file that is generated automatically. The contents of the new /etc/resolv.conf, assuming you want to use google DNS.
nameserver 8.8.8.8 nameserver 8.8.4.4
Now disable DNSMasq by commenting it out in /etc/NetworkManager/NetworkManager.conf. Mine look like this.
[main] plugins=ifupdown,keyfile,ofono #dns=dnsmasq no-auto-default=10:0C:29:69:C5:EF, [ifupdown] managed=false
Now restart the NetworkManager
$ service network-manager restart
You can check what DNS is working by
$ nmcli device show | grep IP4.GATE
If you still showing the default localhost or router, try nslookup. It should look like this
$ nslookup anoneh.com Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: anoneh.com Address: 132.147.91.14
You can select a particular DNS server to query
$ nslookup > server 8.8.8.8 Default Server : dns.google Address : 8.8.8.8 > anoneh.com Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: anoneh.com Address: 132.147.91.14
You can achieve similar results with the dig command.
You can also use the following online tools and this.
If you want to clear your DNS cache
$ systemd-resolve --flush-caches
For network tools.