Posted By

whitetiger on 11/09/06


Tagged

regex python cli ip internet world delicious hello documentation dangerous ethernet interface cgi networking tcpip


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

anayhk
fukami
pulczynski


Python - get Interface ethernet


 / Published in: Python
 

  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  

You need to login to post a comment.