Skip to content

Instantly share code, notes, and snippets.

@bgunebakan
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgunebakan/aa85ded369e5aff1f452 to your computer and use it in GitHub Desktop.
Save bgunebakan/aa85ded369e5aff1f452 to your computer and use it in GitHub Desktop.
get ip address of interface.if interface does not exist i will return 'no connection interface'
import netifaces
satInterface = 'ppp0' #finding interface
interfaceList = netifaces.interfaces() #create interface list
if satInterface in interfaceList: #find interface in list
netifaces.ifaddresses(satInterface) #get ip
ip = netifaces.ifaddresses(satInterface)[2][0]['addr']
print ip
else:
print 'no connection interface'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment