1pip install netifaces
2
3################
4
5from netifaces import interfaces, ifaddresses, AF_INET
6for ifaceName in interfaces():
7 addresses = [i['addr'] for i in ifaddresses(ifaceName).setdefault(AF_INET, [{'addr':'No IP addr'}] )]
8 print '%s: %s' % (ifaceName, ', '.join(addresses))
9