DNS lookup

John Burton john.burton at jbmail.com
Sun Mar 9 13:16:24 CET 2003


"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")






More information about the Python-list mailing list