linux hosts
Linux修改/etc/hosts
hosts文件
hosts格式配置
hosts文件格式
hosts文件作用


参考文献
#/etc/host.conf
order hosts,bind #解析器查询顺序是文件/etc/hosts,然后是DNS
multi on #允许主机拥有多个ip地址
nospoof on #禁止ip地址欺骗
Linux下hosts,host.conf,resolv.conf的区别
Linux下这三个文件都位于 /etc/目录下,在这里区分一下
1.hosts文件.
和Windows系统下的host的文件相类似,就是一个文本文件,里面存放一些IP和域名的对应关系。
2.host.conf. #解析器查询顺序配置文件
例:cat < /etc/host.conf
multi on
order hosts,bind
order hosts bind 表示先查询本地hosts文件,如果没有结果,再尝试查找BIND dns服务器。
3. resolv.conf
配置Linux系统DNS服务器的配置文件:
cat < /etc/resolv.conf
nameserver *****
nameserver *****
如果/etc下没有hosts文件,就需要新建一个,然后写入自己的数据,比如:
vi /etc/hosts
10.86.0.115 BEJ-TEST-01
:wq
then ping BEJ-TEST-01
# ping BEJ-TEST-01
PING BEJ-TEST-01 (10.86.0.115): 56 data bytes
64 bytes from 10.86.0.115: seq=0 ttl=64 time=0.848 ms
64 bytes from 10.86.0.115: seq=1 ttl=64 time=0.530 ms
64 bytes from 10.86.0.115: seq=2 ttl=64 time=0.478 ms
64 bytes from 10.86.0.115: seq=3 ttl=64 time=0.551 ms
64 bytes from 10.86.0.115: seq=4 ttl=64 time=0.435 ms
64 bytes from 10.86.0.115: seq=5 ttl=64 time=1.820 ms
64 bytes from 10.86.0.115: seq=6 ttl=64 time=0.464 ms
64 bytes from 10.86.0.115: seq=7 ttl=64 time=0.871 ms
64 bytes from 10.86.0.115: seq=8 ttl=64 time=0.862 ms
就可以看到已经起作用了。

浙公网安备 33010602011771号