Netmask
A netmask is a 32-bit mask used to divide an IP address into subnets and specify the networks available hosts. In a netmask, two bits are always automatically assigned. For example, in 255.255.225.0, "0" is the assigned network address; and in 255.255.255.255, "255" is the assigned broadcast address. The 0 and 255 are always assigned and cannot be used.
Below is an example of a netmask and an example of its binary conversion.
| Netmask: | 255. | 255. | 255. | 255 |
|---|---|---|---|---|
| Binary: | 11111111 | 11111111 | 11111111 | 11111111 |
| Netmask length | 8 | 16 | 24 | 32 |
Counting out the bits in the binary conversion allows you to determine the netmask length. In the above example, you have an example of a 32-bit address. However, this address is a broadcast address and does not allow any hosts (computers or other network devices) to be connected to it.
A commonly used netmask is a 24-bit netmask, as seen below.
| Netmask: | 255. | 255. | 255. | 0 |
|---|---|---|---|---|
| Binary: | 11111111 | 11111111 | 11111111 | 00000000 |
| Netmask length | 8 | 16 | 24 | -- |
Using a 24-bit netmask, the network would be capable of 2,097,150 networks or 254 different hosts with an IP range of 192.0.1.x - 223.255.254.x. This is commonly plenty of addresses for one network.
A simple formula can be used to determine the capable amount of networks a netmask is able to support. With the understanding that the netmask length is 24, subtract three from that number, e.g. 24-3 = 21. Once this number is determined, take 2 to the x power - 2 (where x is the number you just determined). Which would be 2^21 - 2 = 2,097,150. You are subtracting two from this number because of the broadcast and network addresses that are already being used.
To determine the amount of hosts a netmask is capable of supporting is similar to the above. As you see by the above chart, we have eight zeros. This number is similar to the 21 we determined earlier. Therefore, 2 to the x power - 2. (where x is the number of zeros in the netmask). This would be 2^8 - 2 = 254. Again, two is subtracted from this number to account for the broadcast and network addresses.
Below is a breakdown of each of the commonly used network classes.
| Class | Netmask length | # of networks | # of hosts | Netmask |
|---|---|---|---|---|
| Class A | 8 | 126 | 16,777,214 | 255.0.0.0 |
| Class B | 16 | 16,382 | 65,534 | 255.255.0.0 |
| Class C | 24 | 2,097,150 | 254 | 255.255.255.0 |
Also see: Binary, IP address, Network definitions, Subnet Mask
