jsakamoto / ipaddressrange

.NET Class Library for range of IP address, both IPv4 and IPv6.
Mozilla Public License 2.0
370 stars 71 forks source link

Is this supposed to be a valid IP Address parse? If so, would you mind explaining why? #55

Closed finalcut closed 5 years ago

finalcut commented 5 years ago
bool isValid = IPAddressRange.TryParse("46000-65536", out IPAddressRange range);

it is identified as valid and the range is :

"0.0.179.176-0.1.0.0"

I don't understand what is happening there.

finalcut commented 5 years ago

I think I've answered my own question.

ip addresses are actually numbers in base 256 so 65536 is converted via base 256 where each part of the ip4 address is a different number in base 256

So 65536 in this format is 0.1.0.0 which is basically the same as 0.001.000.000

This tool will help others as confused as me https://www.ipaddressguide.com/ip

Plug in an ip address like 127.0.0.1 and see what the decimal number is (2130706433)