主机名-f和socket.getfqdn()返回不同

时间:2018-08-17 08:36:18

标签: python linux networking centos centos7

我正在Windows 10的VMVirtualbox中使用CentOS7。在/etc/hosts文件中,我添加了Windows PC abc.def.xyz.abc的ipaddress。 并将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

0 个答案:

没有答案