Skip to content

Instantly share code, notes, and snippets.

@packetchef
Created January 19, 2016 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save packetchef/0d301522b1fc4735bed5 to your computer and use it in GitHub Desktop.
Save packetchef/0d301522b1fc4735bed5 to your computer and use it in GitHub Desktop.
import socket
import struct
def ip2dec(ip):
packedIP = socket.inet_aton(ip)
return struct.unpack("!L", packedIP)[0]
def dec2ip(dec):
return socket.inet_ntoa(struct.pack("!L", dec))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment