Debian – What does “search localdomain” do in resolv.conf

debiandnsresolv.conf

When connecting to the Internet by default I get two lines in my /etc/resolv.conf file:

I'd like to know what exactly "search localdomain" means there.
I see that it's probably related to DNS but I'm not sure how and couldn't find sufficient information on that. I also don't understand why it's getting removed when I disconnect from the Internet – shouldn't it stay there?
I'm using Debian 9.1 with KDE.

Best Answer

man resolv.conf:

search

Search list for host-name lookup.

The search list is normally determined from the local domain name; by default, it contains only the local domain name. This may be changed by listing the desired domain search path following the search keyword with spaces or tabs separating the names. Resolver queries having fewer than ndots dots (default is 1) in them will be attempted using each component of the search path in turn until a match is found. (...)

localdomain here is your domain. When you make a DNS query with no dot (actually with fewer dots than the configuration value ndots), this domain is automatically added to your query. I.E. if you look up for foo, the actual DNS lookup will be for foo.localdomain.

Related Question