I am running my code on multiple VPSes (with more than one IP, which are set up as aliases to the network interfaces) and I am trying to figure out a way such that my code acquires the IP addresses from the network interfaces on the fly and bind to it. Any ideas on how to do it in python without adding a 3rd party library ?
Edit I know about socket.gethostbyaddr(socket.gethostname())
and about the 3rd party package netifaces
, but I am looking for something more elegant from the standard library ... and parsing the output of the ifconfig
command is not something elegant :)