About/etc/hosts and/etc/resolv.conf learning

Source: Internet
Author: User
Tags nameserver

1./etc/hosts

Hosts file, officially known as the static table lookup for host name, in Chinese for the host name query static tables. Hosts file is a Linux system in charge of IP address and domain name Fast resolution of the file, in ASCII format in the "/etc" directory, the file name is "hosts" (different versions of Linux, this configuration file may also be different.) For example, the corresponding file in Debian is/etc/hostname). The Hosts file contains a mapping between the IP address and host name, and also includes the alias of the hostname. In the domain name resolution process, will first query whether there is (DOMAIN->IP) mapping in/etc/hosts, if not, will initiate domain name resolution request to local DNS. Commonly used domain names and IP address mappings can be added to the hosts file to achieve fast and convenient access.

In general, the/etc/hosts configuration format is:

IP address host name hostname alias 1 hostname alias 2 .....
For example, the contents of a/etc/hosts file on a Redhat service are as follows:
:: 1         localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1   localhost Localhost.localdomain Localhost4 Localhost4.localdomain4
Note: (1):: 1 for the IPV6 loopback address, equivalent to IPv4 127.0.0.1 (2) through the above configuration can be found that host name aliases can have many


2./etc/resolv.conf

/ETC/RESOLV.CONF is configured with a local DNS server, which means that when the confidential domain is accessed, a DNS resolution request is initiated to the DNS server configured in/etc/resolv.conf. The/etc/resolv.conf configuration file structure is as follows:

NameServer x.x.x.x
nameserver y.y.y.y
nameserver ....
Search sohu.com
domain sohu.com
options Rotate
where nameserver represents a DNS server, nameserver can be configured multiple. When multiple nameserver are configured, a request is made to the first nameserver each time a domain name resolution request is initiated, and a request is initiated to the second nameserver if the first nameserver timeout is requested. So in general, the more nameserver in the front, the greater the pressure. If you configure the options rotate, you will initiate requests to these nameserver in the form of polling, in which case the pressure of each nameserver is similar.

Search and domain indicate that when we ask for an incomplete domain name, for example we want to request parsing www.sohu.com, but we only use www (nslookup www), Then domain and search will be filled as www.sohu.com. In addition, domain and search are configured at the same time, who is in the back who takes effect.

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.