Change DNS Ubuntu

This is small example how to manually change DNS in Ubuntu. This example working for most linux distro.

What is DNS?
The Domain Name System (DNS) is a hierarchical naming system built on a distributed database for computers, services, or any resource connected to the Internet or a private network. DNS translates domain names meaningful to humans into the numerical identifiers associated with networking equipment for the purpose of locating and addressing these devices worldwide. For example google.com DNS records looks like
google.com. 1 IN A 74.125.232.20
google.com. 1 IN A 74.125.232.16
google.com. 1 IN A 74.125.232.17
google.com. 1 IN A 74.125.232.18
google.com. 1 IN A 74.125.232.19Change DNS recommend if you use VPN and dont want to be tracked! Some websites can determine your location using DNS records. So lets change our DNS to google public DNS. However you can use your VPN provider DNS or any other DNS servers.

1) To change DNS in Ubuntu we need edit file /etc/resolv.conf

Open Terminal from Applications -> Accessories -> Terminal and use this command to edit DNS zones file

sudo nano /etc/resolv.conf

if you’re not root system will ask to confirm editing with password

2) Comment existing records using # symbol and add new DNS records like:

nameserver x.x.x.x

where x.x.x.x is your new DNS server.

For google public DNS use 8.8.8.8 and 8.8.4.4

if you use StrongVPN you can use their own DNS servers: 216.131.94.5 and 216.131.95.20

On my example I comment my local settings #nameservers 192.168.1.1 and add 2 new records for google DNS

use Ctrl + x to save file and sure confirm all

3) Some linux services can change DNS zones files automatically so to prevent this we will lock file.

Use this command to lock file

sudo chattr +i /etc/resolv.conf

To unlock (if you want to change DNS again) you will need this command:

sudo chattr -i /etc/resolv.conf

All done, DNS changed :)

Tags: ,.
Home

2 Comments so far

Trackbacks/Pingbacks

Leave a comment

Name(required)
Mail (required),(will not be published)
Website(recommended)

Fields in bold are required. Email addresses are never published or distributed.

Some HTML code is allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
URLs must be fully qualified (eg: http://vpnblog.info),and all tags must be properly closed.

Line breaks and paragraphs are automatically converted.

Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.