getent 主机无法解析主机名

时间:2021-05-18 06:25:54

标签: resolve gethostbyname

这是我的 /etc/hosts

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

192.168.35.65   hadoop1.localdomain     hadoop1
192.168.35.66   hadoop2.localdomain     hadoop2
192.168.35.67   hadoop3.localdomain     hadoop3
192.168.35.68   hadoop4.localdomain     hadoop4
192.168.35.69   hadoop5.localdomain     hadoop5

当我尝试'getent hosts hadoop2'时,它返回正常

[root@hadoop5 getent]# getent hosts hadoop2
192.168.35.66   hadoop2.localdomain hadoop2

但是当我尝试“getent hosts hadoop2.localdomain”时,它无法解析

[root@hadoop5 getent]# getent hosts hadoop2.localdomain
::1             localhost

这是我的 /etc/nsswitch.conf

passwd:     files sss
shadow:     files sss
group:      files sss
#initgroups: files sss

#hosts:     db files nisplus nis dns
hosts:      files dns myhostname

# Example - obey only what nisplus tells us...
#services:   nisplus [NOTFOUND=return] files
#networks:   nisplus [NOTFOUND=return] files
#protocols:  nisplus [NOTFOUND=return] files
#rpc:        nisplus [NOTFOUND=return] files
#ethers:     nisplus [NOTFOUND=return] files
#netmasks:   nisplus [NOTFOUND=return] files

bootparams: nisplus [NOTFOUND=return] files

ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files sss

netgroup:   nisplus sss

publickey:  nisplus

automount:  files nisplus sss
aliases:    files nisplus

和/etc/resolve.conf

# Generated by NetworkManager
search localdomain
nameserver 8.8.8.8

谢谢。

0 个答案:

没有答案