How do I edit the “/etc/resolv.conf” file?
Use text editor such as vi or gedit from Linux desktop:
# vi /etc/resolv.conf
There are three main configuration directives in /etc/resolv.conf:
nameserver # DNS server IP
domain # Domain Name of local host
search # Which Domain to search
The “nameserver” directive
The nameserver directive points out to the IP address of a Name Server.
nameserver <IP address>
It can be your own Name Server, some public Name Server or the Name Server of your’s ISP.
Note: Up to 3 name servers may be listed.
Example:
nameserver 192.168.0.100
nameserver 8.8.8.8
nameserver 8.8.4.4
The “domain” directive
Local domain name.
domain <local domain name>
Example:
domain domain.com
nameserver 192.168.0.100
nameserver 8.8.4.4
How the “domain” directive in the “resolv.conf” file works?
You can use domain directive for resolving short host-names – e.g. test.
So if you have the following in your /etc/resolv.conf:
domain example.com
Then your computer will try to resolve test.example.com.
The “search” directive
Search list for hostname lookup. The search list is normally determined from the local domain name but it can be set to a list of domains.
search <search list>
Example:
search example.com company.net
nameserver 192.168.0.100
nameserver 8.8.8.8
How the “search” directive in the “resolv.conf” file works?
You need to use search directive for resolving short host-names – e.g. test.
So if you have the following in your /etc/resolv.conf:
search example.com company.net
Then your computer will try to resolve test.example.com followed by test.company.net. It will return the first query that was successful.