Because IPv4 addresses are hierarchical, there needs to be some way of distinguishing between the network portion of the address and the host portion. To accomplish this, an IPv4 address must be paired with a network mask, which is also sometimes called a subnetwork mask or simply a subnet mask or mask. A network mask is a 32-bit string of binary characters that defines which portion of the address represents the network and which portion of the address represents the specific host.
The rules for creating a network mask are as follows:
1in the subnet mask defines a network bit.
0in the subnet mask defines a host bit.
So an IPv4 address by itself really tells us nothing. We can make some guesses based on other information that will come later, but for now we need to have a subnet mask paired with an IPv4 address in order for us to know where the device is located and what its unique identity is.
Historically, networks were broken down and divided up for use through the use of address classes. This was accomplished through the use of network masks. When people starting breaking down larger networks into smaller network known as subnetworks, the term subnetwork mask came into use. All of these terms are now used interchangeably.
Ways to Write a Network or Subnet Mask
There are three ways to denote a subnet mask:
- In binary:
- In decimal:
- In slash notation:
Each of these says the same thing: the first 24 bits of the 32-bit mask are 1, and the last 8 bits of the mask are 0. This tells us that when compared to an IPv4 address, the first 24 bits define the network portion of the address, and the last 8 bits define the host portion. If we look back at the address from the beginning of this blog and add to it this subnet mask, we get the following:
00000000 (subnet mask)
0 (address and then mask separated by a single space)
24 (address and mask using the / to separate address from mask)
In all three cases we can say that the network portion of the address
192.168.1 and that the host portion is .