Pyhton ip Range in dash format expansion

Viewed 15

i have an input of ip range as string such as

'192.168.1.0-255'

or

'192.168.0-255.0-255'

with any python library, such as ipaddr or netaddr

is there a way that already exist to convert these inputs to list of ip such as

['192.168.1.0', '192.168.1.1', '192.168.1.2', '192.168.1.3' ... ... ]

and

['192.168.1.0', '192.168.1.1', '192.168.1.2', '192.168.1.3' ... ...  '192.168.2.0', '192.168.2.1']

etc

Question number 2 : if a very wide range such as

192.0.0.0-192.255.255.255   

or

192.0-255.0-255.0-255

is given

How to check if an ip is in the range without taking too much time ?

thank you very much

0 Answers
Related