Python - get Interface ethernet


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. from socket import *
  2. import fcntl
  3. import struct
  4.  
  5. def get_ip_address(ifname):
  6.  
  7. s = socket(AF_INET, SOCK_STREAM)
  8. return inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', ifname[:15]))[20:24])

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.