Python hostname-f和socket.getfqdn()返回不同的
我正在Windows 10的VMVirtualbox中使用CentOS 7。在Python hostname-f和socket.getfqdn()返回不同的,python,linux,networking,centos,centos7,Python,Linux,Networking,Centos,Centos7,我正在Windows 10的VMVirtualbox中使用CentOS 7。在/etc/hosts文件中,我添加了Windows PC的IP地址abc.def.xyz.abc 并将hostname更改为abc.def.xyz.abc 但当我运行以下命令时,输出是不同的: $ python -c 'import socket;print socket.gethostname()' abc.def.xyz $ python -c 'import socket;print socket.getfqd
/etc/hosts
文件中,我添加了Windows PC的IP地址abc.def.xyz.abc
并将hostname
更改为abc.def.xyz.abc
但当我运行以下命令时,输出是不同的:
$ python -c 'import socket;print socket.gethostname()'
abc.def.xyz
$ python -c 'import socket;print socket.getfqdn()'
windows-xzv.abcdomain.com
$ hostname -f
abc.def.xyz
$ python -c 'import platform;print platform.node()'
abc.def.xyz
Systemd破坏了网络的这一部分。另请参见。现在可以工作了,我更改了/etc/nsswitch.conf中的顺序,将文件放在dns前面