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?

user235412
  • 109
  • 1
  • 1
  • 2
  • 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 '14 at 08:35

2 Answers2

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)

MadHatter
  • 79,770
  • 20
  • 184
  • 232
Sverre
  • 753
  • 2
  • 12
  • 23
  • 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 '14 at 08:37
  • 1
    No problems - thanks for taking it so well. +1 from me, by the way - good answer. – MadHatter Jul 31 '14 at 08: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.
Mohammed Noureldin
  • 541
  • 1
  • 11
  • 25
Sven
  • 98,649
  • 14
  • 180
  • 226