DNS lookup
Alessio Pace
puccio_13 at yahoo.it
Sun Mar 9 07:20:16 EST 2003
John Burton wrote:
> "Alessio Pace" <puccio_13 at yahoo.it> wrote in message
> news:eTFaa.3697$Fc.114939 at tornado.fastwebnet.it...
>> Is there a portable way to do a DNS lookup? I am developing in Unix
> (Linux)
>> but I would prefer avoiding the use of Unix specific command line tools.
>> I need both translation from machine name to IP and from IP to machine
>> name. Thanks.
>
> import socket
>
> print socket.gethostbyname("example.com")
> print socket.gethostbyaddr("192.168.0.1")
Thank you both guysm you were really helpful. It is amazing to see problem
solved in Python in one line of code :-D
--
bye
Alessio Pace
More information about the Python-list
mailing list