Socket.gethostbyaddr() return empty aliaslist in linux but not in windows

466 Views Asked by At

Python's socket.gethostbyaddr() return empty aliaslist on linux

I've tried with Python2 and Python3 on both Windows and Linux. It works in windows but not on Linux (both Ubuntu and RedHat) using the same IP to resolve of course. I also did a wireshark capture on both system and we clearly see the DNS answer containing all aliases.

import socket
print(socket.gethostbyaddr('192.168.11.1'))

On windows I get an answer like so which is OK:

('test123.com', ['alias1.test123.com', 'alias2.test123.com'], ['192.168.11.1'])

On linux I get :

('alias1.test123.com', [], ['192.168.11.1'])

Anybody knows the fix?

0

There are 0 best solutions below