Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The domain and search options in resolv.conf

Let's say you have a resolv.conf file that's something like this.

nameserver 192.168.0.7
nameserver 192.168.0.8
domain somedomain.local

Then let's say you just changed it to this.

nameserver 192.168.0.7
nameserver 192.168.0.8
search somedomain.local

Would these both do the same thing? Is one slightly better than the other?

Why would declaring both a domain and search not be recommended?

like image 325
LINUX G33NYUS Avatar asked Sep 12 '25 03:09

LINUX G33NYUS


2 Answers

The existence of both keywords are probably historically. Only one of them can be specified in the resolv.conf (the parser built into glibc is supposed to use the last one it encounters). The search keyword is slighty more powerful, since it allows multiple entries, and has the ndots option.

like image 53
Stian Skjelstad Avatar answered Sep 13 '25 18:09

Stian Skjelstad


man 5 resolv.conf currently reads:

The domain directive is an obsolete name for the search directive that handles one search list entry only.

Stian Skjelstad summarized the benefits of using search over domain nicely.

like image 25
Stefan van den Akker Avatar answered Sep 13 '25 17:09

Stefan van den Akker