how to find subnet mask from IP address

The IPv4 Subnet Mask, also referred to interchangeably as just subnet mask or netmask, is a part of IPv4 addressing. In functionality, it works like an Address Separator discussed earlier. Today i will explain how to find subnet mask from IP address ?

It merely indicates the length, from leftmost-to-right, of the general part of the address and doing so makes the specific part of the address obvious. In IPv4 addressing, the technical term that is used to describe the general part of an address is called the network portion of the address. Similarly, the technical term that is used to describe the specific part of an address is called the host portion of the address. Therefore, in an IPv4 address of a computer, the network portion indicates where the computer is physically located, and the host portion uniquely identifies the computer itself. It is important to note that, each IPv4 address has a corresponding subnet mask. Also, a host means a computer, a cell phone, a PDA or some kind of a network device or an interface that is connected to the network.

To reiterate, an IPv4 address has two(2) distinct components, a network portion and a host portion. The corresponding subnet mask is used to separate these two portions. Without a corresponding subnet mask it would be difficult to identify which computer(device) a given IPv4 address belongs to.

how to find subnet mask from IP address

To explain how a subnet mask works, lets recall the IPv4 addresses discussed earlier.

Example 11a: An IPv4 address (in binary format)

11000000 . 10101000 . 00000001 . 00011101

Example 11b: The same IPv4 address as in example 11a (in dotted decimal notation)

192 . 168 . 1 . 29

As discussed earlier, in example 11a, the binary format of an IPv4 address has four (4) parts and each part is represented by zeros(0) and ones(1). These zeros and ones are also known as binary digits or simply bits. Each part of the address is also known as an octet, since each octet represents eight(8) bits. Therefore, as shown in example 11a, a binary format of a typical IPv4 address is represented by four(4) octets, each separated by a dot (period). The leftmost octet is known as the 1st octet which makes the rightmost octet as being the 4th.

In example 11b, the IPv4 address is identical to example 11a, except it is represented in dotted decimal notation. This type of IPv4 representation also has four(4) parts, each part representing the equivalent decimal value of the corresponding octet of the binary format of the address.

Now, if we look at the addresses shown in example 11a & 11b, it would be impossible to know which computer those addresses belong to without knowing the corresponding subnet mask. Without it, one could arbitrarily say that the network portion of the IPv4 address shown above is “192.168.” or “192.168.1.” or even just “192.” This would make “1.29″ or “29″ or even “168.1.29″ accordingly, to be the host portion of address.

The format of a subnet mask is identical to an IPv4 address. It can be represented in either a binary format or a dotted decimal notation. There is a 3rd way of representing a subnet mask known as the CIDR notation, which will be discussed later. A subnet mask contains a series of consecutive bits of  ’1′s ending with a series of consecutive bits of  ’0′s. The number of ’1′s, counting from leftmost-to-right, indicates the length of the network portion of the corresponding IPv4 address. The ending series of ’0′s represent the host portion of the IPv4 address.

Note, in a binary format, a subnet mask almost always starts with a series of consecutive ’1′s and ends with consecutive ’0′s.

how to find subnet mask from IP address

Below is the IPv4 address shown in example 11a with a corresponding subnet mask.

Example 12a: An IPv4 address and a corresponding subnet mask (in binary format)

IPv4 Address:  11000000 . 10101000 . 00000001 . 00011101

Subnet Mask:   11111111    . 11111111     . 11111111 . 00000000

Example 12b: The same IPv4 address as in example 12a and the corresponding subnet mask (in dotted decimal notation)

IPv4 Address: 192 . 168 . 1 .  29

Subnet Mask:  255. 255. 255 . 0

In example 12a, the subnet mask shows that there are twenty-four consecutive ’1′s, counting from left-to-right, which represent the length of the network portion of the IPv4 address. The rest of the ’0′s, in this case a total of eight(8) bits, represent the host portion of the address.

In example 12a, the decimal value of 255 in the subnet mask represents eight(8) consecutive ’1′s. Hence, twenty-four consecutive ’1′s followed by eight(8) ’0′s are represented by 255.255.255.0.

The following examples show the same IPv4 addresses discussed above but the subnet masks are shown in CIDR notations.

Example 13a: An IPv4 address (in binary format) and a corresponding subnet mask shown in CIDR notation.

IPv4 Address:  11000000 . 10101000 . 00000001 . 00011101/24

Example 13b: The same IPv4 address as in example 13a, with a corresponding subnet maskin CIDR notation

IPv4 Address: 192 . 168 . 1 .  29/24

In examples 13a & 13b, ‘/24′ represents the subnet masks of the corresponding IPv4 addresses. ‘/24′ means a series of consecutive ’1′s, counting from leftmost-to-right, representing the length of the network portion of the IPv4 address. The rest of the bits, a total of eight (32-24=8), can be assumed (implied) to be a series of consecutive ’0′s, which would represent the host portion of the address.

It sure looks like the CIDR notation is the way to go in understanding subnet masks. In a way it is, but not quite so. To understand how an IPv4 addressing works, as I’ve mentioned before, there cannot be any jumping over binary numbers.

how to find subnet mask from IP address

Please pay attention to the following discussions very carefully. Understanding it, would separate the best IP network engineers from the rest of the pack. Notice that so far I’ve been using the terms “network portion” and the “host portion” of an IPv4 address. However, I did not define or mention the corresponding “network address” and the “host address” which are also something we need to find out.

The following includes the corresponding network addresss and host addresses of the IPv4 addresses shown in examples 12a & 12b.

Example 14a: An IPv4 address, subnet masknetwork address and host address (in binary format)

IPv4 Address:  11000000 . 10101000 . 00000001 . 00011101

Subnet Mask:   11111111    . 11111111     . 11111111 . 00000000

Network Address: 11000000.10101000.00000001.00000000

Host Address: 11000000 . 10101000 . 00000001 . 00011101

Example 14b: An IPv4 address, subnet masknetwork address and host address (in dotted decimal notation)

IPv4 Address: 192 . 168 . 1 .  29

Subnet Mask:  255. 255. 255 . 0

Network Address: 192 . 168 . 1 . 0

Host Address: 192 . 168 . 1 . 29

In examples 14a & 14b, the network address is the network portion of the address followed by a series of consecutive ‘o’s, which originally represented the host portion of the address. And the host address is the network portion of the address followed by the number represented by the host portion of the address.

“That’s it? So, what was the big deal?,” one may ask. Congratulations! It was easy for you because you have patiently either read this article or other books on IPv4 addressing and it shows that you have come a long way. It was also easier due to the fact that, all along I’ve been using an IPv4 address with a very simple subnet mask. This type of IPv4 address and the corresponding subnet mask is known as the IPv4 Class C addressing. In IPv4 Class C addressing, it is easier to extract the network address from the network portion of the address and host address from the host portion of the address. It so happens that most of the network engineers start out by learning Class C addressing and move on to IPv4 subnets or subnetting, where they need to dissect a bigger network into several smaller networks. Although, Class C IPv4 addressing is the right place to start, more often than not the distinction between the concepts “network portion” and “network address” gets blurred. The same is true between “host portion” of an address and a “host address.” Blurring these concepts will make learning subnetting very difficult or challenging.

how to find subnet mask from IP address

For now, just remember and memorize the following. Keeping these in mind will help you learn IPv4 subnetting faster.

The “network portion” of an address is not the same as the “network address.”

The “host portion” of an address is not the same as the “host address.”

The “network portion” of an address may not readily reveal what the “network address” may look like.

The “host portion” of an address may not readily reveal what the “host address” may look like.

The “network portion” of an address may reveal more than one “network address.”

The “host portion” of an address may reveal more than one “host address.”

Leave a Comment