Changing DNS server on ubuntu

Posted under » Ubuntu » Linux on 1 August 2017

If you don't define your desktop or server's DNS it is probably using your 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 still showing the default localhost or router, try nslookup.

$ 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

web security linux ubuntu GIT svn Raspberry apache mysql php drupal cake symfony javascript Ajax css