Get IP Address (only linux)


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



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.