sockets: bind to external interface

Hans Georg Schaathun hg at schaathun.net
Mon Apr 25 15:37:24 EDT 2011


Is there a simple way to find the external interface and bind a
socket to it, when the hostname returned by socket.gethostname()
maps to localhost?

What seems to be the standard ubuntu configuration lists the local
hostname with 127.0.0.1 in /etc/hosts.  (I checked this on two ubuntu
boxen, on only one of which I am root.)  Thus, the standard solution
of binding to whatever socket.gethostname() returns does not work.

Has anyone found a simple solution that can be administered without
root privileges?  I mean simpler than passing the ip address 
manually :-)

TIA
-- 
:-- Hans Georg



More information about the Python-list mailing list