Dhcp client configuration to change the default DNS servers to Open DNS

Dhcp client configuration to change the default DNS servers to Open DNS

The DNS servers of my ISP is always behaving erratically. The DNS look up times are abysmally large and some times I get an address not found error while browsing. On ubuntu/debian systems the DNS servers are specified in /etc/resolv.conf. I tried to edit /etc/resolv.conf and put open dns servers as default DNS servers. But, my ISP supplies their DNS server address along with IP address for the system via DHCP. Every time my system renews its DHCP lease. my /etc/resolv.conf is also rewritten with their DNS address.

My /etc/resolv.conf ( supplied by ISP) looks like this.

$ cat /etc/resolv.conf
domain kartook.com
search kartook.com
nameserver 202.88.238.3
nameserver 202.88.238.5
nameserver 202.88.231.2

There is a trick I used to make Open DNS servers as my default DNS server.

Edit /etc/dhcp3/dhclient.conf and look for the line.
#prepend domain-name-servers 127.0.0.1;
Add the following line immediately below the above line.

prepend domain-name-servers 208.67.222.222
prepend domain-name-servers 208.67.220.220
#

You can also put any other DNS servers.

Now renew the lease with

$ sudo dhclient eth0

The new /etc/resolve.conf looks like this.

$ cat /etc/resolv.conf
domain kartook.com
search kartook.com
nameserver 208.67.220.220
nameserver 208.67.222.222
nameserver 202.88.238.3
nameserver 202.88.238.5
nameserver 202.88.231.2

DNS look up is made from open dns.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.