Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save benjaminlaird/93958daf7207e7faa767c09afe495441 to your computer and use it in GitHub Desktop.
Save benjaminlaird/93958daf7207e7faa767c09afe495441 to your computer and use it in GitHub Desktop.
Simple IP prefix calculation
def get_ip_network(ip):
# ip as integer not dotted quad str
mask = 4294967040 #int(ipaddress.ip_address(u'255.255.255.0'))
return ip & mask
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment