Created
August 22, 2020 17:55
-
-
Save benjaminlaird/93958daf7207e7faa767c09afe495441 to your computer and use it in GitHub Desktop.
Simple IP prefix calculation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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