socket.gethostbyaddr() question

Roy Smith roy at panix.com
Sun Jan 15 11:07:41 EST 2006


"Harlin Seritt" <harlinseritt at yahoo.com> wrote:
> I have a list of IP addresses I am testing with socket.gethostbyaddr().
> For the most part, I am able to get a hostname returned to me when I
> run gethostbyaddr(). I am also hoping this will allow me to tell if a
> computer is up or down.

Gethostbyaddr() simply does a lookup in some sort of name resolution 
database (typically DNS, but could be YP/NIS, hostfile, etc).  The ability 
to look a name up in the database has absolutely no correlation with 
whether that node is up, down, or unreachable.

To tell if a machine is up or down, you need to probe the machine directly.  
Typically, this is done by sending it an ICMP Echo Request (commonly known 
as ping), but that's not foolproof.  A machine could be up, but unreachable 
because of network or routing problems.  A machine could be intentionally 
not answering pings.  A firewall in the way could be filtering out ping 
packets.  Or, the Echo Request or Echo Reply could have simply gotten lost 
somewhere on the network.

What, exactly, are you trying to do?



More information about the Python-list mailing list