Posted under » Ubuntu » Linux on 1 August 2017
If you don't define your desktop or server's DNS it is probably using your router DHCP's DNS which sometimes may not ideal.
To do this, follow these steps.
$ 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 list | grep IP4.DNS #or nm-tool | grep DNS
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.