How to convert list like:
94.192.0.0/14
94.0.0.0/12
93.96.0.0/16
To:
94.192.0.0-94.195.255.255
94.0.0.0-94.15.255.255
93.96.0.0-93.96.255.255
Using python3?
Use the ipaddress
builtin module:
>>> import ipaddress
>>> net=ipaddress.ip_network('94.192.0.0/14')
IPv4Network('94.192.0.0/14')
>>> '%s-%s' % (net[0], net[-1])
'94.192.0.0-94.195.255.255'
With for i in net
you can also enumerate all ip addresses in the network net
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With