Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_ip_addresses():
- ips = {}
- for ifaceName in interfaces():
- addresses = [i['addr']
- for i in ifaddresses(ifaceName).setdefault(AF_INET,
- [{'addr':'No IP addr'}])]
- if len(addresses):
- ips[ifaceName] = addresses[0]
- return ips
- print ( get_ip_addresses())
- """
- #from netifaces import interfaces, ifaddresses, AF_INET
- for ifaceName in interfaces():
- addresses = [i['addr'] for i in ifaddresses(ifaceName).setdefault(AF_INET, [{'addr':'No IP addr'}] )]
- print ( '%s: %s' %(ifaceName, ', '.join(addresses)))
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement