Ubuntu Linux Configure DNS Name Server IP Address ( DNS Client )

by Vivek Gite on April 13, 2008 · 8 comments

Q. How do I change existing name server IP address? How do I configure DNS name server IP address under Ubuntu Linux / Debian Linux? How do I configure DNS name resolution under Ubuntu Linux?

A. You need to edit /etc/resolv.conf file under Debian / Ubuntu Linux to set Name server IP address that the resolver should query. Up to 3 name server internet IP address can be defined. If there are multiple servers, the resolver library queries them in the order listed.

Ubuntu Linux Configure DNS Name resolution

Type the following command, enter:
$ sudo vi /etc/resolv.conf
Or use nano text editor:
$ sudo nano /etc/resolv.conf
Append your ISP name server or free fast dns nameservers IP address as follows:
nameserver 208.67.222.222
nameserver 208.67.220.220
nameserver 202.51.5.52

Save and close the file. Test your dns configuration by typing the following commands:
$ host yahoo.com
$ nslookup google.com
$ ping nixcraft.in

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 8 comments… read them below or add one }

1 Carl Friis-Hansen November 8, 2008

I wonder if you are not missing something in the command:
$ sudo /etc/resolv.conf

What about:
$ sudo nano /etc/resolv.conf

or something?

Reply

2 vivek November 11, 2008

Carl,

Thanks for the heads up. The faq has been updated.

Reply

3 Noah Spurrier October 19, 2009

On Ubuntu the settings may get overwritten and will certainly get overwritten after a reboot. This is because Ubuntu dynamically generates the /etc/resolv.conf file.It generates this from file a template where it gives you convenient hooks to add in your own static nameserver definitions. Here is the more modern method.
Edit the template’s tail file:
sudo vim /etc/resolvconf/resolv.conf.d/tail
Add your nameserver lines:
nameserver 208.67.222.222
nameserver 208.67.220.220
nameserver 202.51.5.52
Save the file and then regenerate the resolv.conf file:
sudo /etc/init.d/resolvconf restart


Noah

Reply

4 Jaymes October 26, 2009

@Noah

Default installation of Ubuntu Server 9.04 does not have this ‘feature’. /etc/resolvconf/ does not exist.

Reply

5 Vivek Gite October 26, 2009

@Jaymes,

No it is available and /etc/resolv.conf file do exits for Ubuntu 9.04. It is part of default Linux C library.

@Noah, you need to setup dhclient to avoid overwriting, see:

How To: Make Sure /etc/resolv.conf Never Get Updated By DHCP Client

Reply

6 write March 28, 2011

how about restarting network? it should or not?

Reply

7 Satish Thakur November 14, 2011

Dear Team,

How do i can assign hostname & IP address in Ubuntu? If By using sudo? then how to install sudo…?

Thanks & Regards,
Satish.

Reply

8 kwak December 1, 2011

Hello,

It is perhaps silly question but I don’t really understand from where should I take ip addresses which should be added to /etc/resolv.conf.

I am speaking of those:

nameserver 208.67.222.222
nameserver 208.67.220.220
nameserver 202.51.5.52

Shall I ask my network provider about that or there is an easier method?

Thank you for help!

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 4 + 12 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: