In networking, a subnet mask is a bitmask that defines the range of IP addresses for a network. In order to identify an IP address on a network, your computer must know the subnet mask for that network.
The Subnet Mask
1. What is a Subnet Mask?
The subnet mask is a bitmask that tells the router which octet of the IP address corresponds to which host ID. This is important because it allows the router to route traffic to the correct destination without needing to know the IP address of each and every host on the network.
2. How Do We Create A Subnet Mask?
To create a subnet mask, you first need to divide your IP address into eight equal parts. You then use the first octet of this number as your mask (this is also known as the network ID). The next seven octets are used to identify each individual host on your network. So, for example, if your IP address is 192.168.1.30, your subnet mask would be 255.255.255.0.
When configuring a router, you need to know the octet of the subnet mask. This octet tells the router the corresponding host ID.
The octet for a subnet mask is always 8 bits in size. The first two bits (bits 0 and 1) determine the network number, or the number range that the subnet covers. The next four bits (bits 2 through 7) determine the host number. In this example, bit 6 would be set to 1, meaning that the router would use that host number for all requests targeting addresses within the network with a network number of 192.168.1.0 through 192.168.1.255.
The Host Id
When a user wants to connect to a remote server, they need to provide the server’s host id. This is a number that uniquely identifies the server on the network.
The host id is usually an 8-digit number, but it can also be a 16- or 24-digit number. The router uses this number to determine which octet of the subnet mask will correspond to the host id.
For example, if the router’s subnet mask is 255.255.255.0, and a user wants to connect to server with host id 10.5.5.5, their host id would be 10.5.5.10 in octet notation. The router would then use the first octet of its subnet mask (255) to determine the corresponding host id (10).
The Corresponding IP Address
When you want to connect to a remote server, your computer needs to know the IP address of that server. Your computer looks up this address by asking for it from a network router.
The network router is like a telephone exchange. It routes packets of information across the Internet, and it knows which computers are located on which networks. When you ask the router for the IP address of a particular server, it will give you that information in the form of an IP address (an integer number).
IP addresses are divided up into groups called octets. Each octet is made up of 8 bits (2 bytes). The first octet is always reserved for the host identifier (the number that tells your computer which network this IP address belongs to), and the last 7 octets are used to uniquely identify each computer on the network.
For example, if you wanted to connect to a remote server located at 192.168.1.5, your computer would use the following sequence of octets: 192.168.1.0 through 192.168.1.255 (the first octet would be set to 1, and the last 7 would be set to 5).
When configuring an octet-based subnet mask, the first two octets specify the network ID and the last two octets specify the host ID. The router will then use this information to determine which IP addresses fall within that subnet.