Created
May 24, 2017 11:23
-
-
Save Akendo/6cf70aa01f92ab2f03ae6c27480f713e to your computer and use it in GitHub Desktop.
Converting a netmask to CIDR with vanilla python
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 netmask_to_cidr(m_netmask): | |
return(sum([ bin(int(bits)).count("1") for bits in m_netmask.split(".") ])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very useful!