For most users the DNS servers provided by their ISP may suffice, but some user may need DNS that are faster, safer and with far fewer restrictions for online browsing.
To change the DNS servers in Ubuntu, you need to modify the file ‘dhclient.conf’.
Open the terminal and give the following command:
sudo nano /etc/dhcp/dhclient.conf
Then uncomment the line below and add the DNS you want:
prepend domain-name-servers 8.8.8.8, 8.8.4.4;
Save the file (CTRL+X) and reboot. Now you’re using the chosen DNS (Google DNS if you used the ones listed above).