The subnet mask plays an important role in computer networking. It’s used to determine the subnetwork an IP address belongs to. It achieves this by masking the part of the IP address that will be used to create the subnetworks and not masking the portion of the IP address that will be used for host addresses.

Networks based on TCP/IP use subnet masking to split an IP address into two parts; the first part is used to divide the network into logical subnetworks, the second part is used to assign computers, otherwise known as hosts, to subnetworks. The subnet mask and IP address are interdependant; you look at the IP address in relation to the subnet mask to determine how many subnetworks and how many hosts per subnetwork there will be. We will focus solely on class C addresses as these are the most likely class readers of this article will encounter.

The subnet mask looks a lot like an IP address. It’s a 32 bit address that’s divided into 4 octets; each octet contains 8 bits.

A typical subnet mask looks like this: 255.255.255.192

The 255.255.255.192 address looks like this in binary: 11111111.11111111.11111111.11000000

How do we get 11111111.11111111.11111111.11000000 from 255.255.255.192? It’s actually quite easy.

Here’s a table that shows you the decimal value of each bit in an octet:

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1

We can tell by using this table as a reference that:

The 1st bit in an octet is worth 128

The 2nd bit in an octet is worth 64

The 3rd bit in an octet is worth 32

The 4th bit in an octet is worth 16

The 5th bit in an octet is worth 8

The 6th bit in an octet is worth 4

The 7th bit in an octet is worth 2

The 8th bit in an octet is worth 1

By adding the value of the bits represented by a 1 together, we can tell what the decimal value will be. Let’s use the first octet as an example. The first octet is represented by all 1’s which is 11111111, if we add the 1st to 8th bits, we get a value of 255 (128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255).

Looking at the subnet mask, we have a lot of 1’s followed by some 0’s (11111111.11111111.11111111.11000000). Consider the string of 1’s in the last octet as the portion used by the network for creating subnetworks and the string of 0’s in the last octet as the portion used by the hosts for each subnetwork. Remember, the only octet we’re interested in is the last one. Think of it this way, we are borrowing a few bits from the last octet in order to create the subnets. The more bits needed to create subnetworks, the fewer the bits remaining to create host addresses within each subnetwork.

It may help you to think of it like this; the more hosts needed in each subnetwork, the fewer subnetworks you’re able to create. The more subnetworks created, the fewer the hosts able to reside on each subnetwork. We will go through a few examples, but first I need to explain a little more about class C subnet masks.

The subnet mask for Class C addresses, when not subnetted, looks like this: 255.255.255.0 which in binary is: 11111111.11111111.11111111.00000000

Let’s go through a few examples so you can see how borrowing bits from the last octet will effect the number of subnetworks and the number of hosts per subnetwork.

We know the subnet mask 255.255.255.192 looks like this in binary: 11111111.11111111.11111111.11000000

Based on an IP address of 192.168.1.x and a subnet mask of 255.255.255.192, these are the addresses related to the usable subnets

192.168.1.64 (Reserved for Network)

192.168.1.65 to 192.168.1.126 (Range of usable)

192.168.1.128 (Reserved for Network)

192.168.1.129 to 192.168.1.190 (Range of usable)

Let’s go through another example.

We know the subnet mask 255.255.255.240 looks like this in binary: 11111111.11111111.11111111.11110000

We can see that 4 bits have been borrowed to create subnetworks, leaving 4 bits for host addresses. 2 to the power of 4 equals 16, minus 2 leaves 14 usable subnetworks each with 14 usable host addresses. Here’s a list of all usable subnets and the range of addresses those subnets use:

192.168.1.16 (Reserved for Network)

192.168.1.17 to 192.168.1.30 (Range of usable)

192.168.1.32 (Reserved for Network)

192.168.1.33 to 192.168.1.46 (Range of usable)

192.168.1.48 (Reserved for Network)

192.168.1.49 to 192.168.1.62 (Range of usable)

192.168.1.64 (Reserved for Network)

192.168.1.65 to 192.168.1.78 (Range of usable)

192.168.1.80 (Reserved for Network)

192.168.1.81 to 192.168.1.94 (Range of usable)

192.168.1.96 (Reserved for Network)

192.168.1.97 to 192.168.1.110 (Range of usable)

192.168.1.112 (Reserved for Network)

192.168.1.113 to 192.168.1.126 (Range of usable)

192.168.1.128 (Reserved for Network)

192.168.1.129 to 192.168.1.142 (Range of usable)

192.168.1.144 (Reserved for Network)

192.168.1.145 to 192.168.1.158 (Range of usable)

192.168.1.160 (Reserved for Network)

192.168.1.161 to 192.168.1.174 (Range of usable)

192.168.1.176 (Reserved for Network)

192.168.1.177 to 192.168.1.190 (Range of usable)

192.168.1.192 (Reserved for Network)

192.168.1.193 to 192.168.1.206 (Range of usable)

192.168.1.208 (Reserved for Network)

192.168.1.209 to 192.168.1.222 (Range of usable)