8

I've usually seen two kinds of entries in /etc/resolv.conf on certain servers. The domain-name-servers entry specifies which DNS to use for resolving hostnames to IP addresses. Recently I saw an entry for search IP_ADDRESS. So here's my question. What's the difference between a nameserver and a search domain?

1
  • 1
    The value specified with search must be a domain rather than an IP address. It is plausible that if the DHCP server is misconfigured and neither server nor client validate the value, that you could end up with an IP address being written into resolv.conf. It may also be that the invalid value in resolv.conf was placed there manually.
    – kasperd
    Jul 31, 2014 at 8:35

2 Answers 2

15

the search indicate what domain(s) to append to your host name in a search. for example if you run this command :

ping myserver

if you do not have anything in the search domain, it will search for "myserver" in your hostfile, and if nothing there, it will return

unknown host

but if you add search mydomain.com

then the same ping would return

64 bytes from myserver.mydomain.com (some ip): icmp_seq=1 ttl=62 time=415 ms

(provided the "myserver.mydomain.com actually exist, and reply to ping requests)

nameserver on the other hand is the IP address of your actual DNS server, where you look up all hostnames that is not in your hosts file.

edit: added some more details, and the 2nd part of the question (nameserver)

2
  • sorry, I accidentally deleted someones edit of my post.. while I was editing it myself.. I have added the change that was made myself. thanks for help.
    – Sverre
    Jul 31, 2014 at 8:37
  • 1
    No problems - thanks for taking it so well. +1 from me, by the way - good answer.
    – MadHatter
    Jul 31, 2014 at 8:51
3
  • A name server entry tells the system what name servers to ask for name resolution.
  • A search domain provides a default domain name for searches. If you provide example.net and example.com as search domains and try to contact the host server1, the system will look for server1.example.net and server1.example.com without you having to type out the full domain.
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.