Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-13-2016, 07:30 AM   #1
LQ Newbie
Registered: Dec 2014
Posts: 3

Rep: Reputation: Disabled
Setting DNS


How to set up DNS without editing /etc/resolv.conf? Is this possible? I set up my network that:

#ifconfig eth0 up XXX.XXX.XXX.XXX
#route add default gw XXX.XXX.XXX.XXX
#echo "nameserver" > /etc/resolv.conf

Is possible set DNS address other way?

Sorry for my english.
Old 02-13-2016, 11:25 AM   #2
Senior Member
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
You're actually supposed to add one or two DNS servers to /etc/resolv.conf (unless you're running your own DNS with bind). Your ISP should provide you two DNS addresses, those would be the entries in /etc/resolv.conf; you can also use public DNS addresses, e.g., Google provides free DNS at and Those are US addresses, you need to find reliable external DNS server addresses that are electrically close to you, check with ping and pick servers with the shortest times. For example
ping -c 5
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=55 time=612 ms
64 bytes from icmp_seq=2 ttl=55 time=899 ms
64 bytes from icmp_seq=3 ttl=55 time=1245 ms
64 bytes from icmp_seq=4 ttl=55 time=1023 ms
64 bytes from icmp_seq=5 ttl=55 time=563 ms

--- ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4000ms
rtt min/avg/max/mdev = 563.975/869.042/1245.838/255.288 ms, pipe 2
/etc.resolv.conf would look like this
search com
That's all you need; note that you do not want more than two DNS server addresses -- if the first one is not available it will fall over to the next and that is delayed buy multiple tries at the first listed address. You want reliable external addresses.

If, however, you're only using a LAN, with no outside access, you can enter those addresses in /etc/hosts and never bother with DNS at all. The implication is that /etc/hosts is for fixed IP addresses of the form
# for loopbacking
# local servers    foo.lan foo    bar.lan bar
That allows direct connections (with, say, SSH) as well as web access to a system configured with HTTP.

On my systems, configured with fixed IP addresses, /etc/hosts is used for both computers and devices (Ethernet printer and plotter) and external servers such as, and a few others -- TCP/IP looks at /etc/hosts first, then at /etc/resolv.conf and having the addresses in /etc/hosts completely avoids a DNS look up. You may want to look into that for a small number of external servers; keep in mind that you have to edit these things and DNS can turn out to be the better bet.

You can choose to use DHCP rather than fixed IP, but you will need to identify your DHCP servers so that they are "findable" on your LAN (you give them a name and address in the configuration file). Personally, I think that on a small (up to about 20 devices) that fixed IP is easier and works just fine but more than 20 or so would be better with DHCP. It's a balancing act.

You can mix fixed IP and DHCP. DHCP usually starts leasing addresses at 100 (like, fixed IP between 2 and 99 works just fine too (don't use, that's the loopbback address and things won't work if you do that).

You can, as hinted, run BIND. However, be aware that will be a lot of traffic (you're running your own DNS server). Could be useful if you have questionable network service, might not be worth much if you do have unreliable network service -- if you can't get out, nobody can get in either irrespective of DNS addresses.

Hope this helps some.
Old 02-14-2016, 04:16 PM   #3
Registered: Feb 2016
Posts: 49

Rep: Reputation: Disabled
I'm no expert, but I think Linux zone files could be another way for configuring DNS..


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
The best way of setting up a DNS AdultFoundry Linux - Newbie 1 10-29-2015 01:02 PM
dns setting invader44 Linux - Newbie 1 12-23-2009 11:17 AM
Setting up DNS UnknownFear Linux - Networking 3 04-10-2004 02:39 AM
DNS setting Eddie9 Linux - General 1 04-21-2002 10:48 PM
setting up DNS deepak Linux - Networking 4 03-31-2001 01:06 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:19 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration