Linux /etc/hosts 主机名静态查询表

用途:

关联主机名和IP地址

在机器启动时,在DNS正常工作前,需要知道一些主机名和IP地址的映射关系,这个映射关系就保存在/etc/hosts文件中,在DNS不能正常工作是,系统中所有的网络程序将查看该文件以决定IP地址对应的主机名。

格式:

每行一个IP地址

IP_address canonical_hostname [aliases...]

注释:

从 #开始,到一行的结束。

示例一:

127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

示例二:

# The following lines are desirable for IPv4 capable hosts
       127.0.0.1       localhost

       # 127.0.1.1 is often used for the FQDN of the machine
       127.0.1.1       thishost.mydomain.org  thishost
       192.168.1.10    foo.mydomain.org       foo
       192.168.1.13    bar.mydomain.org       bar
       146.82.138.7    master.debian.org      master
       209.237.226.90  www.opensource.org

       # The following lines are desirable for IPv6 capable hosts
       ::1             localhost ip6-localhost ip6-loopback
       ff02::1         ip6-allnodes
       ff02::2         ip6-allrouters

 

posted @ 2016-07-05 13:24  RushoutAsia  阅读(458)  评论(0编辑  收藏  举报