From the course: Linux System Engineer: Web Servers and DNS Using Apache, NGINX, and BIND

Configure resolv.conf

- [Narrator] There are two client-side name resolution files that we should be concerned with in Enterprise Linux 7, resolv.conf and nsswitch.conf. The purpose of resolv.conf is to provide a list of global DNS service for our client to query when resolving DNS names. The format of the file is fairly simple. There are two columns. The first column will have either search, domain, nameserver, sortlist, or option in it. If it is search, it will be followed by up to six domain names with a total of 256 characters that will be appended if you try to resolve something incomplete. For instance, if you tried resolving the word test and the search line included localnet.com, ford.com, and apple.com, it would try to resolve test.localnet.com, test.ford.com, test.apple.com, and, lastly, test by itself. One of these domains has to be a local domain name. If you do not include a search line, then it defaults to your local domain name. For instance, if my local domain name was localnet.com and I tried resolving test, my system would resolve test.localnet.com, first, and then try to resolve test, second, even if I did not have a search line. If the first column specifies domain, it will append that domain to the end of a short name. Normally this is our local domain name, but if we wanted to change it we could. For instance, if we had domain, space, otherdomain.com and we resolved test, it would try to resolve it to test.otherdomain.com. You only need to do this if your local domain is not the same as the rest of your network. The keyword we use the most is nameserver. The nameserver keyword is followed by a DNS server IP address to query. For instance, nameserver, space, 4.2.2.2. You can have up to three nameserver lines and the client will query them in the order they're listed. The sortlist keyword allows us to sort IP addresses in certain networks. For instance, if we had sortlist, space, 130.155.160.0, slash, 255.255.240.0, it would allow addresses returned to be sorted in this network. There can be up to 10 network and subnet pairs. The last keyword in the first column is options. The options keyword lets us set DNS client options such as querying the nameservers round robin to spread the load, a timeout, or the number of attempts the client will query the DNS server before giving up. Keep in mind, too, that if you want to set DNS nameservers per network interface, you can do so by adding them to the interface specific network configuration files. The /etc/resolve.conf is a global configuration file. Also, keep in mind that if you set your DNS servers an interface specific configuration file, and you also set the pure DNS director to yes, then those DNS servers will get copied to /etc/resolve.conf automatically.

Contents