What is Subnet Mask
As explained in previous lesson about IPv4 addresses, an IPv4 address is a 32-bit binary number used to identify a computer uniquely in an IPv4 based TCP/IP network. IPv4 addresses are expressed as four 8-bit (4 * 8 = 32 bits) numbers, separated by a dot. Each 8-bit part is called as an octet. Example of an IPv4 address is 172.16.0.100.
What is subnet mask? Subnet mask is also a 32-bit binary number. Subnet mask is also expressed as four 8-bit (4 * 8 = 32 bits) numbers, separated by a dot. Example of a subnet mask is 255.255.0.0.
A 32-bit IPv4 address (example: 172.16.0.100) is further divided into a network part and a host part. We need a mechanism to separate an IPv4 address to a network part and a host part. Network part is used to identify the network that the computer belongs to and the host part is a unique identifier of that computer within the network. If you express an IPv4 address as plain as 172.16.0.100, there is no way to identify which is the network part and which is the host part.
To identify which part of an IPv4 address is the network part and which part of the IPv4 address is host part, we need another identifier called as "subnet mask". The purpose of the subnet mask is to identify which part of an IPv4 address is the network part and which part is the host part.
Below image shows the default subnet masks for Class A, Class B and Class C IPv4 networks.
Please note below points.
- If all host part bits are binary number "0", that is the network address.
- Configurable IPv4 addresses must contain atleast one non-zero bit in any host part octet.
- If all the host part bits are binary number "1", that is the directed broadcast address for that network.
Consider below example of two Class B neworks. Two computers with IPv4 addresses 172.16.0.100/255.255.0.0 172.17.0.100/255.255.0.0 as shown in below image belong to two different networks, 172.16.0.0 and 172.17.0.0 network respectively. Computers located in different networks cannot communicate directly in IPv4. You need a router to communicate between two different IPv4 networks. Please refer below image, which shows two different Class B networks connected together by routers.
We have two networks in above image, connected together by routers. As marked, the network address of one network ("Network 1") is 172.16.0.0 with a subnet mask of 255.255.0.0 and the network address of other network ("Network 2") is 172.17.0.0 with a subnet mask of 255.255.0.0.
Wherever "255" octet appears in the subnet mask, corresponding octet in IPv4 address belongs to the network part. Wherever "0" appears in the subnet mask, corresponding octet in IPv4 address belongs to the host part. In other words, "172.16" is the network address of "Network 1" and "172.17" is the network address of "Network 2". Please note that the previous example is shown in decimals but actual calculations are done using binary numbers.
Next paragraph explains above concept using binary numbers.
- Wherever binary number "1" appears in subnet mask, corresponding bit in IPv4 address is the network part.
- Wherever binary number "0" appears in subnet mask, corresponding bit in IPv4 address is the host part.
Please refer below two images to get more clear view about how subnet masks work for 172.16.0.0 and 172.17.0.0 network addresses. Please note that all host part are "0" for network addresses.
Please refer below two images to get more clear view about how subnet masks work for IPv4 addresses; 172.16.0.100 and 172.17.0.100.
You have learned the concept of subnet masks in IPv4 and default subnet masks for Class A, Class B and Class C IPv4 networks. Click "Next" link below to continue.