[Python-bugs-list] [ python-Bugs-577977 ] socket.gethostbyaddr is too strict

noreply@sourceforge.net noreply@sourceforge.net
Fri, 05 Jul 2002 17:23:17 -0700


Bugs item #577977, was opened at 2002-07-05 20:23
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=577977&group_id=5470

Category: Python Library
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Dave Cinege (dcinege)
Assigned to: Nobody/Anonymous (nobody)
Summary: socket.gethostbyaddr is too strict

Initial Comment:
While using socket.gethostbyaddr() I discovered it will    
not deal with 'bad' ip addresses.     
    
IE: print socket.gethostbyaddr('192.168.0.400')    
python2.2   
socket.gaierror: (-2, 'Name or service not known')   
python2.1   
socket.error: host not found    
   
Now you may be wondering WTF I'm using a bad IP.   
Good question. It is the end result of my quest to make   
machines (that are offline) have their mac addresses  
availab;e for query. DHCP is too difficult, so I tried some  
trickery with DNS. Of the several ways to do this, the  
easist is to create a PTR of the host, and offset it's IP by  
say 300 with a new host name equal to it's mac.   
  
IE  
100 IN  PTR zen-machine.psychosis.com. 
400 IN  PTR 00-A0-CC-60-FE-D1.psychosis.com. 
  
Again WHY all of this? It would be nice to execute  
'wakeonlan <hostname>' instead of keeping track of  
MAC's.  : > 
  
It's all works lovely with BIND 8.2.X. I assume as well  
with bind 9. Bind 8 and bind 9 utils can make the query.  
  
# host 192.168.0.400  
400.0.168.192.in-addr.arpa domain name pointer  
00-A0-CC-60-FE-D1.psychosis.com.  
  
But I found out when writing my util to wrap this all up  
Python's socket pukes.   
  
Now the question is, is socket doing the right thing? It's  
not so clear when you put it in terms of DNS. DNS deals  
with strings, and those string need not nessasarly follow  
the rules of TCP/IP. (BIND's actions above are a perfect  
example) However BIND is no benchmark for proper  
operation.  : P  
 
What I do know is I've had to revert to executing the 
'host' command externally instead of using Pythons 
native interface. 
 
Dave 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=577977&group_id=5470