python - How to calculate how much Ip Addresses have between two Ip Addresses? -
i have 2 ip addresses, , want count how many ip addresses there in range between two.
example:
ip_start = "127.0.0.0" ip_end = "127.0.1.1" sum_of_ip_address = 257 does know if python has me accomplish this?
short solution using ipaddress package.
import ipaddress ip1 = int(ipaddress.ipv4address(unicode('127.0.0.0'))) ip2 = int(ipaddress.ipv4address(unicode('127.0.1.1'))) print ip2 - ip1
Comments
Post a Comment