What is the subnet mask?

John Savill

March 4, 1999

2 Min Read
ITPro Today logo in a gray background | ITPro Today

A. As has been shown the IP address consists of 4 octetsand is usually displayed in the format 200.200.200.5, however this address onits own does not mean much and a subnet mask is required to show which part ofthe IP address is the Network ID, and which part the Host ID. Imagine theNetwork ID as the road name, and Host ID as the house number, so with "54Grove 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 whichpart is the Host ID.

For example, with an address of 200.200.200.5, and a subnet mask of255.255.255.0, the Network ID is 200.200.200, and the Host ID is 5. This iscalculated 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 thesubnet 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 asfollows:

Class A : 001.xxx.xxx.xxx to 126.xxx.xxx.xxx uses subnet mask 255.0.0.0 asdefault
Class B : 128.xxx.xxx.xxx to 191.xxx.xxx.xxx uses subnet mask 255.255.0.0 asdefault
Class C : 192.xxx.xxx.xxx to 224.xxx.xxx.xxx uses subnet mask 255.255.255.0 asdefault

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

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

Host A 200.200.200.5
Host B 200.200.200.9
Host C 200.200.199.6
Subnet Mask 255.255.255.0

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

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like