How to calculate how much Ip Addresses have between two Ip Addresses?
Question: I have two Ip Addresses, and I want to count how many Ip Addresses there are
in the range between the two.

Example:

    
    
    IP_START = "127.0.0.0"
    
    IP_END = "127.0.1.1"
    
    SUM_OF_IP_ADDRESS = 257
    

Does anyone know if python has anything to help me accomplish this?


Answer: Short solution using the `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
    

