sockets: bind to external interface

Hans Georg Schaathun hg at
Mon Apr 25 21:37:24 CEST 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 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 :-)

:-- Hans Georg

More information about the Python-list mailing list