initial v0.1
This commit is contained in:
32
genRange.py
Executable file
32
genRange.py
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import struct
|
||||
import socket
|
||||
import netaddr
|
||||
|
||||
def usage():
|
||||
print('generate ip list from range')
|
||||
print( '<startip> <endip>')
|
||||
print( 'example: ./%s 1.1.1.1 1.1.1.255')
|
||||
print
|
||||
|
||||
if len(sys.argv)<3:
|
||||
usage()
|
||||
exit()
|
||||
|
||||
s = sys.argv[1]
|
||||
e = sys.argv[2]
|
||||
|
||||
i=netaddr.IPRange(s,e)
|
||||
ss = i.first
|
||||
se = i.last
|
||||
|
||||
o=0
|
||||
res = se-ss
|
||||
while o != res + 1:
|
||||
conv_ip = ss + o
|
||||
print(socket.inet_ntoa(struct.pack('!L', conv_ip)))
|
||||
o+=1
|
||||
Reference in New Issue
Block a user