     Next: How to use the Up: Network Addresses, Masks, and Previous: Network Address   Contents   Index

## Calculating the Network Mask

If you know how many addresses are in your network then you can calculate the network address very easily. Lets first assume that you have 256 addresses or less. If this is the case then the network mask will start as 255.255.255. something. You can take the number 256 and subtract the number of addresses that you have in your network to give you the last number in your mask. Here is a simple table:

 IP Addresses Network Mask 256 255.255.255.0 128 255.255.255.128 64 255.255.255.192 32 255.255.255.224 16 255.255.255.240 8 255.255.255.248 4 255.255.255.252

You can take those numbers and convert them into bits and count the bits. The number 255 converted to binary is 11111111. That is 8 bits. The whole IP address is 32 bits broken into groups of 8 bits. 255.255.255.0 would be converted to 11111111.11111111.11111111.00000000. If you look at the number you will notice that the number is a group of 1s followed by a group of 0s. We would call this a /24 network because there are 24 1s. All of the network masks can be converted into a group of 1s followed by a group of 0s. 255.255.255.128 would be converted into 11111111.11111111.11111111.10000000. This would be a /25 network because there are 25 1s in a row before the 0s.     Next: How to use the Up: Network Addresses, Masks, and Previous: Network Address   Contents   Index
Joseph Colton 2002-09-24