Created
July 29, 2017 08:58
-
-
Save riverfor/d80b450536fe46a21708829921b04fc2 to your computer and use it in GitHub Desktop.
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 socket | |
import fcntl | |
import struct | |
interfaces = [ | |
b"eth0", | |
b"eth1", | |
b"eth2", | |
b"wlan0", | |
b"wlan1", | |
b"wifi0", | |
b"ath0", | |
b"ath1", | |
b"ppp0", | |
] | |
def getlan(ifname): | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
#print(ifname[:15]) | |
print( socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', ifname[:15]))[20:24]) ) | |
for int in interfaces: | |
getlan(int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment