Linux Local parsing file/etc/hosts description "original"

Source: Internet
Author: User

Windows domain name Local resolution file hosts is able to have a domain name on multiple IPs, if there is a problem with IP, can go to resolve to other IP

Linux local parsing file/etc/hosts, whether it can also do so. Here's a test.

Let's take a look at #解析器查询顺序配置文件

cat /etc/host.confmulti on

If you want to set the parsing order, the following

#表示先查询本地hosts文件, if there is no result, try to find the BIND DNS server

Order hosts, bind multi on

Use on or off as an option. This determines whether a host in the/etc/hosts can have several IP addresses, which is usually referred to as "multihomed." This flag is not useful for DNS or NIS requests.

Compiling the Hosts file

Cat /etc/hosts127.0. 0.1    localhost localhost.localdomain localhost4 localhost4.localdomain4::1         localhost Localhost.localdomain localhost6 localhost6.localdomain610.72. 16.60 api.weixin.qq.com 10.72. 16.62 api.weixin.qq.com 101.226. 212.27 api.weixin.qq.com

Test effect

[[Email protected] ~]# Telnet api.weixin.qq.com theTrying10.72.16.60... telnet:connect to address10.72.16.60: Connection refusedtrying10.72.16.62... telnet:connect to address10.72.16.62: Connection timed outtrying101.226.212.27... Connected to Api.weixin.qq.com.Escape character is'^]'. Connection closed by foreign host.

You can see that 10.72.16.60, 62 are inaccessible, and finally resolved to 101.226. on the 212.27.

But there will be a time-out. Connection timed out

Conclusion: As long as the local parsing profile opens multion, it can be a domain name for multiple IP

Configure configuration files for a Linux system DNS server

/etc/resolv.conf #配置Linux系统DNS服务器的配置文件

#表示DNS服务器域名是shanghai. The address of the Abc.com,dns server is 172.10.10.20

Search Shanghai. ABC.com

NameServer 172.10.10.20

Haha, at this time we ping sha-node-h on the local machine, successfully return the corresponding IP address 172.20.30.1, in addition, Ping www.baidu.com on the application server successfully returns the resolved IP address.

Reference

http://blog.csdn.net/hello_yang213/article/details/49364527

Https://zhidao.baidu.com/question/124826853.html

https://blog.xupeng.me/2013/05/15/multiple-ips-with-hosts/

Reprint please specify the source!

Linux Local parsing file/etc/hosts description "original"

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.