Created
October 3, 2012 06:49
-
-
Save apackeer/3825451 to your computer and use it in GitHub Desktop.
Convert CIDR mask to dotted decimal
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
from socket import inet_ntoa | |
from struct import pack | |
bits = 0 | |
mask = 25 | |
for i in xrange(32 - mask,32): | |
bits |= (1 << i) | |
dotted_decimal = inet_ntoa(pack('>I', bits)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment