我/etc/hosts
在ubuntu 12.04机器上有以下文件
127.0.0.1 localhost
10.248.27.66 ec2-50-112-220-110.us-west-2.compute.amazonaws.com puppetmaster
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
但是,host命令不能puppetmaster
正确解析名称,而telnet命令可以
root@ip-10-248-34-162:/home/ubuntu# host puppetmaster
Host puppetmaster not found: 3(NXDOMAIN)
root@ip-10-248-34-162:/home/ubuntu# telnet puppetmaster 8140
Trying 10.248.27.66...
Connected to ec2-50-112-220-110.us-west-2.compute.amazonaws.com.
Escape character is '^]'.
为什么host命令不能解析/ etc / hosts中的条目?
/etc/nsswitch.conf
看起来像这样hosts: files dns
,我将其更改为,hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
但是在两种情况下/etc/hosts
都不会查询,而是直接进行了dns查询。/etc/hosts
当使用诸如dig
或命令时,如何确保首先查询host
?