Last active
August 29, 2015 14:15
-
-
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'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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