Linux: Setup as DNS Client / Name Server IP Address

by nixcraft on December 1, 2004 · 40 comments

Many new Linux user finds it difficult to setup / modify new name server address (NS1 / NS2).

Local name resolution is done via /etc/hosts file. If you have small network, use /etc/hosts file. DNS (domain name service is accountable for associating domain names with ip address, for example domain yahoo.com is easy to remember than IP address 202.66.66.12) provides better name resolution. To configure Linux as DNS client you need to edit or modify /etc/resolv.conf file. This file defines which name servers to use. You want to setup Linux to browse net or run network services like www or smtp; then you need to point out to correct ISP DNS servers:

/etc/resolv.conf file

In Linux and Unix like computer operating systems, the /etc/resolv.conf configuration file contains information that allows a computer connected to the Internet to convert alpha-numeric names into the numeric IP addresses that are required for access to external network resources on the Internet. The process of converting domain names to IP addresses is called "resolving."

The resolv.conf file typically contains the IP addresses of nameservers (DNS name resolvers) that attempt to translate names into addresses for any node available on the network.

Setup DNS Name resolution

Steps to configure Linux as DNS client, first login as a root user (use su command):

Step # 1: Open /etc/resolv.conf file:

# vi /etc/resolv.conf

Step #2: Add your ISP nameserver as follows:

search isp.com
nameserver 202.54.1.110
nameserver 202.54.1.112
nameserver 202.54.1.115

Note Max. three nameserver can be used/defined at a time.

Step # 3:Test setup nslookup or dig command:

$ dig www.nixcraft.com
$ nslookup www.nixcraft.com

See also:

Featured Articles:

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

We're here to help you make the most of sysadmin work. So, subscribe!

{ 39 comments… read them below or add one }

1 Anonymous August 27, 2005

Very precise brief & 100% helpful

Thanks!!

Reply

2 Anonymous August 28, 2005

This is quite useful when you have DSL or dial up connection and would like to setup dns quickly under Linux. Or even when you can’t browse site on net using domain name but you can browse them (ping them) using the ip-address. This solved my problem as well as Temporary failure in name resolution (which can be caused by ssh, telnet or mail client etc) To browse Internet one need to configure the DNS properly. Thanks for this tiny post.

Reply

3 unamed February 19, 2008

Thnx helped me :)

Reply

4 sathish February 22, 2008

hi;

Im having problem with DNS where it unable to lookup the dns that i have setupd. i have configured my hosts file and resolve.conf but stil not solving my problem. i have statis dns ip from ISP and currently using fedora8. any1 having problem with dns with fc8. i cant surf the internet.it takes long time to resolve suspect that it getting dns from my router. where it not resolving it from what i have edited in the machine. request is tooo slow. anything that could help to solve? need help. i have checked all my setting everything is fine.

Reply

5 Ali durrani March 12, 2008

I need Dhcp ip router in Fc8
anyone here experience of that?

Reply

6 ganesh June 11, 2008

Hi,
I’ve setup the internet connection through PPP dial up and able to get the public IP assigned to me. Also I’ve configured the DNS server address in the /etc/resolv.conf file.
The problem is, I’m able to ping to my ISP’s IP and also to any public IP addresses, but not to any domain names.
ping http://www.google.com, always fails saying unknown host, but at the same time nslookup and dig work fine(able to resove IP from domain name).
What may be the problem?, please do help, Thanks in advance,

–Ganesh

Reply

7 vivek June 11, 2008

try ping google.com

Reply

8 Pothi Kalimuthu December 12, 2008

Thanks a bunch!

I was just looking for this.

Reply

9 pankaj sharma February 17, 2009

domain configer redhate server to clint pc

Reply

10 star May 10, 2009

thanks for the guides, was looking for this

Reply

11 bomy May 19, 2009

how i can config host file

Reply

12 A.Wadud June 20, 2009

i cant add GW address in eth0, how to i add it , plz give me command,

Reply

13 chisao July 16, 2009

for redhat linux, im able to ping the ip address from the client side but not the server name .. i type “neat” and under the tab hosts, i put my address as 123.0.0.5 and hostname as funnybone.123.com but im unable to, mind helping out? thx

Reply

14 June July 26, 2009

hi! i m doing a project on redhat linux 5.3.. my project requires me to setup a dns master server on the server computer. and a client computer have to ping the server and itself by hostname. i m able to use the client computer to ping server computer by hostname and ip. but the client can’t ping itself by hostname. may i know wat is the problem? do i nid to install bind in the client computer as well?
thanks and regards.

Reply

15 Ayie September 15, 2009

use this command to add a default gateway to your server,
route add default gw 192.168.1.1 dev eth0

Reply

16 sachin shinde October 11, 2009

It is very understandable information, And thanks for guiding me.

Reply

17 mosin khan January 9, 2010

i’ve setup dns server on rhel5 and working. clinets are pinging by ip not by name. my server pinging itself by name.
please help me

Reply

18 kumar January 10, 2010

good I was looking for such type of articals really.

Reply

19 ritzrash March 10, 2010

i know my proxy server ip and i put it in the resolve.conf file like explained above

nameserver xxx.xxx.x.xx

however when i do dig http://www.google.com it gives me

; <> DiG 9.2.4 <> http://www.google.com
;; global options: printcmd
;; connection timed out; no servers could be reached

I even tried adding the proxy=xxx.xxx.x.xx: to my yum.conf file

Still getting the same error.. Please suggest

Reply

20 ozgur March 11, 2010

This solved the problem temporariliy, but everytime i reboot my system, resolv.conf is set back to its original state. How can i make this change permanent?

Reply

21 Vivek Gite March 11, 2010

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

Reply

22 ozgur March 11, 2010

Thanks for the help..

Reply

23 Foxx Linux March 17, 2010

great instructions.. 100% accurate.

Reply

24 Lakshman March 23, 2010

Good Information. Helped me in resolving one of critical issue.

Reply

25 maggie May 11, 2010

hey,
i do appreciate for what your doing to us.
i have problem with how to set up dns server using linux in my laptop

Reply

26 Omar, Riverside, California June 4, 2010

Hello.
I am just wondering. Setting up my first web server to run my website.
I got a domain name paid for and a dns thing from them.
Do i just plug this in the resolv.conf file?
I guess my question would be what does the resolve file look like when we are getting a domain name and dns from some company online in order to make our server public?

Reply

27 Omar, Riverside, California June 4, 2010

Sorry but wanted to add another question.
What about IP address do I just pick one out of the air? or set it do Dynamic?
Right now I got my server working in lan as a local server for testing but would like to connect it to the web for my website so hard finding help for this set up. Usually everything is for local server setup.

Reply

28 naresh.singh June 13, 2010

please submit more information about dns configuratio and aleternet dns

Reply

29 Omar June 14, 2010

I got it working thanks. with inadyn setup as the dns part.
I decided to avoid the security issues I would have as a beginner with setting up my own dns server at home.
Thank you for this site. I learned the most important lesson I think which is I am still a beginner and I should take it one step at a time.

Reply

30 Nhoel June 24, 2010

why cant i edit my resolv.conf file?

Reply

31 alva July 15, 2010

you might not have the write permission. issue this command ‘ls -lrt’ you should see at least something like this ‘-rw-r–r– ‘

Reply

32 kadam August 9, 2010

hi

anyone can help me create dns server in redhat linux.

Reply

33 dinesh December 19, 2010

Dear sir,

I have installed two linux (os) & on each OS oracle11g installed on the vmware and now configuring the server and client on linux, And also two databases are created on each OS.

Now i want to configure the client/server but i am not able to connect due to proper ping,IP & host name, so kinly give me the proper steps with connection scripts.

thanks & Regards
Dinesh

Reply

34 sanjay mahajan January 17, 2011

Dear Sir

I am having problwm with Redhat Enterprise Linux 4 about Configuring it as a internet server
I want to use RHEL 4 as a server and windows XP Systems as a clients for sharing internet among them ,

Pls assist me about doing the same

thanking you

sanjay mahajan

Reply

35 hem kumar April 20, 2011

how do i install dns in linux?
please leave da comment?

thanks for helping…

Reply

36 bharat April 21, 2011

but over the selinux and firewall…

Reply

37 Hal Martin July 25, 2011

This does not work on Fedora 13. If you try to edit resolv.conf NetworkManager will overwrite it on restart.

Reply

38 Al Noma September 24, 2011

I configure DNS server by linux………….how i add or login from xp client

Reply

39 Brenzer Hummer November 3, 2011

Short and upto the mark. Appreciate it!!!

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 7 + 7 ?
Please leave these two fields as-is:
Are you a human being? Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: