LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: Disabled
Setting DNS


Hello

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 8.8.8.8" > /etc/resolv.conf

Is possible set DNS address other way?

Sorry for my english.
 
Old 02-13-2016, 10:25 AM   #2
tronayne
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 8.8.8.8 and 8.8.4.4. 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
Code:
ping -c 5 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=612 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=899 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=55 time=1245 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=55 time=1023 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=55 time=563 ms

--- 8.8.8.8 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
Code:
search com
nameserver 8.8.8.8
nameserver 8.8.4.4
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
Code:
# for loopbacking
127.0.0.1
# local servers
192.168.1.10    foo.lan foo
192.168.1.20    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 maps.google.com, linuxquestions.org 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 192.168.1.100), fixed IP between 2 and 99 works just fine too (don't use 192.168.1.1, 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, 03:16 PM   #3
Otherworlds
Member
 
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..
 
  


Reply


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 12:02 PM
dns setting invader44 Linux - Newbie 1 12-23-2009 10:17 AM
Setting up DNS UnknownFear Linux - Networking 3 04-10-2004 01:39 AM
DNS setting Eddie9 Linux - General 1 04-21-2002 09:48 PM
setting up DNS deepak Linux - Networking 4 03-31-2001 12:06 AM


All times are GMT -5. The time now is 11:29 AM.

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