A brief analysis of/etc/resolv.conf files in Linux

Source: Internet
Author: User
Tags domain name server nameserver nslookup

/etc/resolv.conf is a DNS client configuration file that sets the IP address and DNS domain name of the DNS server, and also contains the domain name search order for the host.

The file is a configuration file that is used by the Domain name Resolver (resolver, a library that resolves IP addresses based on the host name). Its format is simple, each line begins with a keyword followed by one or more arguments separated by a space.

Here's what I get from opening/etc/resolv.conf:

[[email protected] ~]# cat /etc/resolv.conf  //查看该文件中的内容# Generated by NetworkManagernameserver 8.8.8.8 //google服务器nameserver 8.8.4.4 //google备用服务器
    • 1
    • 2
    • 3
    • 4
    • 5

Let's take a look at the meaning of the parameters represented in detail here:

1, resolv.conf key words

nameserver    //定义DNS服务器的IP地址domain       //定义本地域名search        //定义域名的搜索列表sortlist        //对返回的域名进行排序
    • 1
    • 2
    • 3
    • 4

Here we give an example of a/etc/resolv.conf:

domain  51osos.comsearch  www.51osos.com  51osos.comnameserver 202.102.192.68nameserver 202.102.192.69
    • 1
    • 2
    • 3
    • 4

The most important is the NameServer keyword , if you do not specify nameserver can not find the DNS server, other keywords are optional.
NameServer indicates that the host specified with this address is the domain name server when resolving the domain name. Where the name servers are queried in the order in which they appear in the file, and only when the first nameserver is unresponsive, the following nameserver are queried, and generally do not specify more than 3 servers.

Domain declares the hostname of the host many programs use it, such as the mail system, when a host without a domain name for the DNS query, also need to use. If there is no domain name, the hostname is used, removing all at the first point (.) The previous content.

search its multiple parameters indicate the order of the domain name query when you want to query a host that does not have a domain name, the host is found separately in the domain that is declared by search.
Domain and search cannot coexist, and if they exist at the same time, subsequent occurrences will be used.

Sortlist allows to get the domain name result to be given a specific sort of its parameters for a network/mask pair, allowing arbitrary order of arrangement.

"Search domainname.com" means that when a hostname is provided that does not include a full domain name, the suffix of the domainname.com is added after the host name, and "nameserver" means that the host specified when resolving the domain name is the domain name server. Where the name servers are queried in the order in which they appear in the file.
where domainname and search can exist at the same time, there can be only one.

Note:
The default/etc/resolv.conf file is not available in Red hat, and its content is created dynamically based on the options given at the time of installation.

We can see through the nslookup that the 8.8.8.8 server is really a Google public DNS server.

[[Email protected] ~]# nslookup>8.8.8.8Server:8.8.8.8Address:8.8.8.8#53Non-authoritative Answer:8.8.8.8. in-addr. arpa name = Google-public-dns-a. google. com. Authoritative answers can found from:In-addr. arpa nameserver = f. in-addr-servers. arpa.In-addr. arpa nameserver = C. in-addr-servers. arpa.In-addr. arpa nameserver = d. in-addr-servers. arpa.In-addr. arpa nameserver = a. in-addr-servers. arpa.In-addr. arpa nameserver = E. in-addr-servers. arpa.In-addr. arpa nameserver = b. in-addr-servers. ARPA.E. in-addr-servers. arpa Internet address =203.119.86.101e. in-addr-servers. arpa has AAAA address2001:DD8:6::101f. in-addr-servers. arpa Internet address =193.0.9.1f. in-addr-servers. arpa has AAAA address2001:67C:E0::1d. in-addr-servers. arpa Internet address =200.10.60.53d. in-addr-servers. arpa has AAAA address2001:13C7:7010::63A. in-addr-servers. arpa Internet address =199.253.183.183b. in-addr-servers. arpa has AAAA address2001:500:87::87c.in-addr-servers.arpa Internet address = 196.216.169.10c .in-addr-servers.arpa has AAAA address 2001:43f8:110::10a .in-addr-servers.arpa Internet address = 199.212.0.73a .in-addr-servers.arpa has AAAA address 2001:500:13::73  
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21st
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28

We can also view the IP address of the domain by nslookup the domain name. This is actually connected to the ping command.

[[Email protected] ~]# nslookup www.baidu.comServer:8.8.8.8Address:8.8.8.8 #53Non-authoritative Answer:www.baidu.com canonical name = Www . A.shifen.com.Name: Www.a.shifenaddress: 183.232.231.173name:www.a .shifen.comAddress: Span class= "Hljs-number" >183.232.231.172    

Brief analysis of/etc/resolv.conf files in Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.