Skip to content

Instantly share code, notes, and snippets.

@aji
Created April 25, 2012 09:45
Show Gist options
  • Select an option

  • Save aji/2488574 to your computer and use it in GitHub Desktop.

Select an option

Save aji/2488574 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys
def fmtip(ip):
s = [ (ip & 0xff000000) >> 24, (ip & 0xff0000) >> 16, (ip & 0xff00) >> 8, (ip & 0xff) ]
return '.'.join([str(x) for x in s])
s = [int(x) for x in sys.argv[1].split('.')]
ip = s[3] + (s[2] << 8) + (s[1] << 16) + (s[0] << 24)
for i in range(32):
print(fmtip(ip | ((1 << (i + 1)) - 1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment