I want to calculate number of number of IP addresses from 2 given IP addresses.
Example: 127.0.1.10
and 127.0.0.200
is 67
IP addresses..
What's easy way of doing this?
I want to calculate number of number of IP addresses from 2 given IP addresses.
Example: 127.0.1.10
and 127.0.0.200
is 67
IP addresses..
What's easy way of doing this?
int IPToInt(string IP)
{
return IPAddress.NetworkToHostOrder(BitConverter.ToInt32(IPAddress.Parse(IP).GetAddressBytes(), 0));
}
int num = IPToInt("127.0.1.10") - IPToInt("127.0.0.200") + 1;
To calculate the amount of IP addresses in a range, or subnet, you need the subnet mask. From this you can know what part of the IP is for the network and which is the hosts. The hosts part will tell you how many hosts are possible within the subnet. The subnet mask was specifically designed so that hardware/software can tell the different what the network part of the IP is, and what the host part of it is.
Without it, I doubt you can know anything.