Transcript for:
IPv4 Subnet Masks

In a previous video, we talked about class-based subnetting and how IP addresses could be assigned a class A, class B, or class C address. But since 1993, we've not used class-based subnetting. Instead, we use classless subnetting. Sometimes you'll see this referred to as classless inter-domain routing, or CIDR. This classless addressing means that we can assign a subnet mask that doesn't or class C arrangements. And instead of referring to the subnet mask in its decimal form, we can simply refer to it as the number of bits. That number of bits is referred to as a CIDR block notation. For example, a decimal subnet mask of 255.0.0.0 is the same as a slash eight CIDR block notation because it has eight individual bits as part of the subnet mask. So it would be very common to see an IP address written as 192.168.1.44 slash 24. Everything with the slash 24 is referring to the number of bits in a subnet mask, and a slash 24 mask would be the same as 255.255.255.0. When you're configuring a device, you're often giving it an IP address, a subnet mask, a default gateway, and very often, a series of DNS servers. Most of the time, an operating system is expecting you to put the subnet mask in as a decimal mask. So for example, in Windows, you may put the IP address, and then you might add in the decimal version of the subnet mask. But if you're using a router or a switch, it may be expecting the CIDR block notation for those masks. So instead of using 255.0.0.0, you would simply input slash 8. Make sure you check. the documentation of the device you're using to see what notation it prefers for the subnet mask. As you've probably seen in our previous examples of subnet masks, the mask consists of a contiguous series of ones followed by zeros. So the ones would be on the left, the zeros would be on the right. For example, here is a subnet mask. You can see the contiguous set of ones on the left and the zeros that are on the right. In this example, you can see three separate octets that are set to 1. So there are 24 1s in this particular mask, and there are eight 0s at the end. If we were to write this out in decimal, it would be 255.255.255.0. And if you were to write this out in CIDR block notation, you would count how many 1s are associated with the subnet mask. In this case, there are 24. So the CIDR block notation would be slash 24. The subnet mask is obviously used to separate the network part of the address from the host part of the address. So for this particular subnet mask, the network address is 24 bits in length, and the host address is 8 bits in length. Let's convert a binary subnet mask to one that is the CIDR block notation for a subnet mask. And we'll take this subnet mask that we have on the screen, which has all ones in the first two octets and all zeros in the last two octets. If we were to count... the number of ones in the subnet mask. We have eight in the first octet, eight in the second octet, none in the third, and none in the fourth. That means the total number of ones in the subnet mask would be 16. So the CIDR block notation would be slash 16. This means that the first 16 bits of the subnet mask are associated with the network and the last 16 bits are associated with the host ID. Let's do another one. In this example, the first three octets are all ones, but the last octet has two ones and six zeros. So let's count the number of ones in this subnet mask. There are eight in the first octet, eight in the second octet, eight in the third octet, and two that are in the fourth octet. If we count all of those together, we have 26. So the CIDR block notation of this subnet mask would be slash 26. The slash 26 means that the first 26 bits of this address are the network part of the address, and the last six bits are reserved for the host ID. And here's one more. In this subnet mask, we have the first octet of all ones, the second octet has four ones and four zeros, and then the third and fourth octets are all zero. Since we are counting number of ones, we have eight in the first octet and four in the second octet. And if you count those together, The subnet mask insider notation would be a slash 12. That means that the first 12 bits are for the network ID, and the last 20 bits would be for the host ID. We've looked at the subnet mask in binary, and we've calculated the Sider block notation, but we often refer to the subnet mask as a decimal value. If we were to convert these binary subnet masks into a decimal value, there are only a certain number of these that you would run into. For example, all zeros would obviously be a decimal zero, but anything that starts with a binary of 1 and the rest zeros would be a decimal of 128. If there are two 1s, it's 192. 3 would be 224, and so on. This means that you could create a chart that shows all eight of the bits within a single octet and what the decimal equivalent would be. We can now use that chart to calculate the Sider block notation and what the decimal representation of that subnet mask would be. So let's look at a subnet mask of all 1s in the first octet. There are four ones in the second octet, and the rest of this would be all zeros. If you refer to our chart, you can see that all ones is 255, four ones and four zeros would be 240, and then of course, all zeros would be zero. And if we were to count the number of ones, we know that correlates back to a slash 12. So a slash 12 SIDR notation is the same thing as 255.240.0.0 in decimal notation. And of course, since there are 12 1s, the network section is 12 bits in length, which leaves the remaining 20 bits available for the host ID. Let's look at a subnet mask we've not seen yet. This one is all 1s in the first octet, all 1s in the second octet. There are three 1s in the third octet. And of course, the rest of this is 0s. If we look at our chart, we can see that, of course, all 1s is 255. And in the octet that has three of these 1s, We refer to the chart that is the same as 224 in decimal. And obviously, all zeros in binary is the same as 0 decimal. If we then count the number of ones in all of these octets, they all add up to 19. So your CIDR block notation would be slash 19, which corresponds back to the decimal representation of 255.255.224.0. This, of course, means that the network part of this address is 19 bits in length. And the host section is 13 bits in length. Of course, we can do this in reverse as well. Let's say that we have a subnet mask that's been given to us as a slash 26 in CIDR block notation. If we were to write this out in binary, that means that we would have all ones in the first three octets and two ones in the last octet. And if we were to refer back to our chart, all ones would obviously be 255. And the last octet that has two ones correlates back. to a 192 in decimal. So a slash 26 where your network ID is 26 bits in length and the host ID is six bits in length is the same as a slash 26 in CIDR block notation or 255.255.255.192 in decimal. Let's do another one where we've been given a slash 20 in CIDR block notation. That means there are 21s. in this particular subnet mask. So your first two octets are all one, and third octet has four ones and four zeros. And of course, the last octet will be all zero. If we refer to our chart, we know that the decimal version of that binary subnet mask will be 255.255.240.0, which is the same as a slash 20 CIDR block notation. That means the network part of this address is 20 bits in length, which leaves us 12. bits available for host IP addresses.