<...snip...>
I got an interesting result if I changed the hostname when system
starting the first time.
>>> import socket
>>> print socket.getfqdn()
zBX.testing
>>> print socket.gethostname()
zBX.testing
>>> print socket.gethostbyaddr(socket.gethostname())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
socket.gaierror: [Errno -2] Name or service not known
gethostbyaddr() (and byname) need to do name server lookups - see the
name service switch configuration (nsswitch.conf).
How/where did you set "zBX.testing" as the hostname?
I would get the same result if I use:
>> print socket.gethostbyaddr("zBX.testing")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
socket.gaierror: [Errno -2] Name or service not known
>>
John
But my /etc/hosts was not changed (just as default),
# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4
localhost4.localdomain4
::1 localhost localhost.localdomain localhost6
localhost6.localdomain6
Just the system with default hostname was changed from
localhost.localdomain into
others could happened that. If we use getfqdn() that situation would not
occur. But
I still don't know the reason why the error happened.
Thanks,
Xu Wang