Making Use Of The search Option In resolv.conf

This guide explains how to use your resolv.conf file to speed up logging into systems that share the same domain name.

The /etc/resolv.conf file configures how the Linux system resolves hostnames. It contains the resolvers that the system will query in order to convert hostnames to IP addresses and vice versa.

In addition to listing resolving servers the resolv.conf file can also take the search option that will save you a great deal of typing in the right situation.

The search option takes a list of space-separated hostnames. Here is an example of the search option being used for two domain names:


These hostnames will be appended to any hostname which does not itself resolve and the new hostname checked to see if it resolves.

This is incredibly useful because many organizations tend to give their servers subdomains a small number of domain names e.g.:

In this situation, putting this line into /etc/resolv.conf:


Means you no longer have to use:


to SSH into but instead can simply type:

ssh root@web1

and will be automatically appended to web1. This will work for any command that uses hostnames on the command line and save you a lot of typing.