How to convert a CIDR prefix to a dotted-quad netmask in Python? -


How can I convert a CIDR prefix into a dotted-quad netmask into a dragon?

For example, if the prefix 12 needs me to return 255.240.0.0 .

You can do it like this:

  def cidr (Prefix): Return socket.inet_ntoa (struct.pack ("& gt; I", (0xffffffff & lt; (32 - prefix)) & amp; 0xffffffff)  

Comments

Popular posts from this blog

c# - Highlight all words containing a letter in a richtextbox -

Admob interstitials not clickable on Nexus 5 (Android 4.4.2) -

java - MigLayout - selective component fill -