Skip to content

Instantly share code, notes, and snippets.

@pgrandin
Created March 2, 2015 22:29
Show Gist options
  • Save pgrandin/7baf07cc1734664ae2aa to your computer and use it in GitHub Desktop.
Save pgrandin/7baf07cc1734664ae2aa to your computer and use it in GitHub Desktop.
List interfaces and associated IPs in python
import netifaces
for interface in netifaces.interfaces():
print interface
if netifaces.AF_INET in netifaces.ifaddresses(interface):
for link in netifaces.ifaddresses(interface)[netifaces.AF_INET]:
if 'addr' in link:
print " --> ", link['addr']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment