📜  resolv conf (1)

📅  最后修改于: 2023-12-03 14:47:04.520000             🧑  作者: Mango

Resolv Conf

Introduction

resolv.conf is a configuration file used by Linux-based operating systems to configure DNS resolver library. It contains information about the domain name servers and the search domain. The resolver library is responsible for resolving domain names to IP addresses.

Location

The resolv.conf file is located in the /etc directory on most Linux systems. You need root access to edit this file.

Syntax

The syntax of resolv.conf file is simple. It consists of one keyword per line followed by its value. The keywords applicable to resolv.conf file are:

  • nameserver: This keyword specifies the IP address of the DNS server to use. Multiple nameserver entries can be added to the file. The resolver will use the DNS servers in the order they are listed.

  • search: This keyword specifies the domain name search list. The resolver library will append the search list to the domain name provided by the user. This means the user only needs to specify the hostname and not the complete domain name.

  • domain: This keyword specifies the domain name of the local host. It is used when a hostname is provided without any domain. The resolver library will append the domain name to the hostname.

  • options: This keyword specifies additional resolver options. Multiple options entries can be added to resolv.conf. Some common options are rotate (to initiate a round-robin selection of domain server to use) and timeout (to set the maximum time allowed for a lookup).

Example
nameserver 8.8.8.8
search example.com
options rotate timeout:2

This resolv.conf file specifies the use of Google's DNS server 8.8.8.8 and a search domain of example.com. It also sets the options to rotate domain server selection and sets a 2 second timeout.

Conclusion

In conclusion, resolv.conf is an important file for configuring DNS resolution under Linux-based operating systems. It allows the user to specify the domain name servers, domain search list, domain name, and additional options. Utilizing this file can make DNS resolution faster and more reliable.