I was trying to get all the local IP addresses (public and private) in python , and the standard socket library seems to provide only information about the IP that resolve your hostname. Here is a quick way how to list all your ip from all interfaces in python.

First you need to install the python netifaces module:

On a debian system you can install the module like this:

sudo apt-get install python-netifaces

You’re done, now you can write the code:

from netifaces import interfaces, ifaddresses, AF_INET

for ifaceName in interfaces():
addresses = [i['addr'] for i in ifaddresses(ifaceName)[AF_INET]]
print ‘%s: %s’ % (ifaceName, ‘, ‘.join(addresses))

on my computer I have an output like this:

lo: 127.0.0.1
eth0: 1.1.1.1
eth1: 192.168.0.1

No Sense ?