IP address and subnet mask used for computing
After knowing the IP address and subnet mask, you can calculate:
1. Network Address
2. broadcast address
3. Address range
4. Several hosts on this website
Example 1: the IP address in the following example is 192 · 168 · 100 · 5. The subnet mask is 255 · 255 · 255 · 0. Calculate the network address, broadcast address, address range, and number of hosts.
1) step-by-step calculation
1) convert the IP address and subnet mask to binary. The subnet mask is the network address and the host address. Network Address before dotted line, host address after dotted line
1) convert the IP address and subnet mask to binary. The subnet mask is the network address and the host address. Network Address before dotted line, host address after dotted line
2) perform and calculate the IP address and subnet mask. The result is the network address.
3) change the network address part of the above network address to full 1, and the result is the broadcast address.
4) The address range is all hosts included in this section.
The network address + 1 is the first host address, and the broadcast address-1 is the last host address.
The address range is: network address + 1 to broadcast address-1
In this example, the Network range is 192 · 168 · 100 · 1 to 192 · 168 · 100 · 254.
That is to say, the following addresses are all in one CIDR block.
192 · 168 · 100 · 1, 192 · 168 · 2... 192 · 168 · 100 · 20... 192 · 168 · 100 · 111... 192 · 168 · 100 · 254
5) number of hosts
Number of hosts = 2 binary number of hosts-2
2 is because the host does not include the network address and broadcast address. In this example, the number of binary hosts is 8 bits.
Number of hosts = 28-2 = 254
2) overall computing
The above example is used together to calculate the process as follows:
Example 2: the IP address is 128 · 36 · 199 · 3. The subnet mask is 255 · 255 · 240 · 0. Calculate the network address, broadcast address, address range, and number of hosts.
1) convert the IP address and subnet mask to binary. The subnet mask is the network address consecutively. The host address is followed by the network address in front of the dotted line and the host address in front of the dotted line.
2) perform and calculate the IP address and subnet mask. The result is the network address.
3) change the network address in the calculation result to 1, and the result is the broadcast address.
4) The address range is all hosts included in this section.
The network address + 1 is the first host address, and the broadcast address-1 is the last host address.
The address range is: network address + 1 to broadcast address-1
In this example, the Network range is 128 · 36 · 192 · 1 to 128 · 36 · 207 · 254.
5) number of hosts
Number of hosts = 2 binary-2
Number of hosts = 212-2 = 4094
2 is because the host does not include the network address and broadcast address.
From the above two examples, we can see that no matter whether the subnet mask is standard or special, you only need to convert the address into binary when calculating the network address, broadcast address, and address count, then, the subnet mask is used to determine the network address before consecutive 1, and then the host address for calculation.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/perddy/archive/2008/10/24/3137637.aspx