What is the subnet mask?

A. As has been shown the IP address consists of 4 octets and is usually displayed in the format, however this address on its own does not mean much and a subnet mask is required to show which part of the IP address is the Network ID, and which part the Host ID. Imagine the Network ID as the road name, and Host ID as the house number, so with "54 Grove Street", 54 would be the Host ID, and Grove Street the Network ID. The subnet mask shows which part of the IP address is the Network ID, and which part is the Host ID.

For example, with an address of, and a subnet mask of, the Network ID is 200.200.200, and the Host ID is 5. This is calculated using the following:

IP Address 11001000 11001000 11001000 00000101
Subnet Mask 11111111 11111111 11111111 00000000
Network ID 11001000 11001000 11001000 00000000
Host ID 00000000 00000000 00000000 00000101

 What happens is a bitwise AND operation between the IP address and the subnet mask, e.g.

1 AND 1=1
1 AND 0=0
0 AND 1=0
0 AND 0=0

There are default subnet masks depending on the class of the IP address as follows:

Class A : 001.xxx.xxx.xxx to 126.xxx.xxx.xxx uses subnet mask as default
Class B : 128.xxx.xxx.xxx to 191.xxx.xxx.xxx uses subnet mask as default
Class C : 192.xxx.xxx.xxx to 224.xxx.xxx.xxx uses subnet mask as default

Where's 127.xxx.xxx.xxx ??? This is a reserved address that is used for testing purposes. If you ping you will ping yourself :-)

The subnet mask is used when two hosts communicate. If the two hosts are on the same network then host a will talk directly to host b, however if host b is on a different network then host a will have to communicate via a gateway, and the way host a can tell if it is on the same network is using the subnet mask. For example

Host A
Host B
Host C
Subnet Mask

If Host A communicates with Host B, they are both have Network ID 200.200.200 so Host A communicates directly to Host B. If Host A communicates with Host C they are on different networks, 200.200.200 and 200.200.199 respectively so Host A would send via a gateway.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.