Posted By

wearetherock on 09/21/09


python linux ip

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Get IP Address (only linux)

 / Published in: Python

  1. def getIpAddress(self, ifname):
  2. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  3. return socket.inet_ntoa(fcntl.ioctl(
  4. s.fileno(),
  5. 0x8915,
  6. struct.pack('256s', ifname[:15])
  7. )[20:24])

Report this snippet  

You need to login to post a comment.