Subnet Prefix: what is it, how long should it be?

Print Friendly, PDF & Email

Windows 10 has a convenient feature which allows you to specify your IP address depending on the wireless network you join – making it far easier to bounce around between multiple offices, work locations, coffee shops, and home. But rather than the standard “Subnet Mask” option we’re all used to seeing, it asks users to fill in their Subnet Prefix Length. What the heck should that number be!?

24

The short answer: Probably 24. That is the same as typing 255.255.255.0 in the old subnet mask field. If you traditionally typed another number in your Subnet Mask, look at the chart below and use the CIDR Prefix for what you’re familiar with typing!

EDIT: I made a video about this that hopefully you’ll be able to absorb MUCH more quickly, and hopefully the visual demonstrations will make more sense!

But why? The long answer: To understand this, you need to first understand subnet masks in general. A subnet mask is really only used to help identify the CLASS of an IP address. It is broken in to four bytes (x.x.x.x) called “octets” (why? Because there are 8 bits in 1 byte. 8 = Octo). The most common example is a class “C” network: 255.255.255.0. In this example only the last byte / octet (the “0” in the subnet mask) can be changed on your current network. This gives you 254 usable addresses (1-255). If you have a class B network, you could use subnet mask 255.255.0.0 (meaning that either of the zeroes could be any combination of numbers from 1-255). Suddenly, you now have 65,534 available IP addresses. This is all done to ensure your devices only talk to the other devices you intend for them to talk to and you don’t accidentally interfere with other people’s nearby networks (routers enforce these rules that don’t allow cross talk between other networks, but this post is running long enough, we won’t get in to all of that).

Then came the Classless Inter-Domain Routing (CIDR) method for allocating IP addresses which helped create the subnetting standard for IPv4 address. The CIDR prefix as simply a shorthand representation which means the exact same thing. Even though it is written as a suffix on the end of an IP address, it is known as the prefix of the subnet. A “/24” network means 254 usable IP addresses, a /16 means 65,534! So, to make sense of this, let’s use some examples: an IP address with a Subnet Prefix such as “192.168.1.0/24” indicates that you are using the IP addressing scheme of 192.168.1.x with the subnet mask of 255.255.255.0 and you have the 254 usable addresses (1-255). If you were to write 192.168.0.0/16, you’re indicating 192.168.x.x and either one of those X’s can be 1-255 – that’s where we get the 65,534 addresses.

So, that’s SUBNET MASKS. But we still haven’t clarified just what is a prefix?

Computers read these addresses in binary, without the dots separating the addresses, and each of the bytes would be represented as 8 bits. If I were to write the number 255 in binary, it would look like 8 1’s in a row. A zero is simply 8 0’s in a row. In other words, a class “C” subnet mask (which we know as 255.255.255.0) would be represented in binary as 11111111111111111111111100000000 or 24 1’s followed by 8 zeroes. Are you starting to see where this is going? The prefix is simply the number of bits in the subnet mask that will be 1’s.

Let’s take one more example to try and drive this all home. Pop quiz time: how many usable addresses are there in a “slash 17” network, or a network with a prefix of 17? Well, let’s line up 17 1’s, and follow it up with 15 zeroes so that we have a total of 32 bits. We’ll take that long binary string and break it into 4 8-bit chunks. If we do a quick conversion and lay it out in octets like an IP address we get 255.255.128.0. If we scroll down and check our chart below, we can see that a prefix of 17 does, in fact, line up with a subnet mask of 255.255.128.0 and yields 32,766 usable IP addresses!

This is an extremely complicated concept and while many people are experts with Server Administration and Active Directory Roles and many other things, this one is heavily math driven and took me a long, long time to wrap my head around. Don’t feel bad if it takes you a while to really get the hang of, but I hope I was able to do a reasonable job of breaking it down for you!

 

Subnet Mask CIDR Prefix Total IP Addresses Usable IP Addresses Number of Class C networks
255.255.255.255 /32 1 1 1/256th
255.255.255.254 /31 2 0 1/128th
255.255.255.252 /30 4 2 1/64th
255.255.255.248 /29 8 6 1/32nd
255.255.255.240 /28 16 14 1/16th
255.255.255.224 /27 32 30 1/8th
255.255.255.192 /26 64 62 1/4th
255.255.255.128 /25 128 126 1 half
255.255.255.0 /24 256 254 1
255.255.254.0 /23 512 510 2
255.255.252.0 /22 1024 1022 4
255.255.248.0 /21 2048 2046 8
255.255.240.0 /20 4096 4094 16
255.255.224.0 /19 8192 8190 32
255.255.192.0 /18 16,384 16,382 64
255.255.128.0 /17 32,768 32,766 128
255.255.0.0 /16 65,536 65,534 256
255.254.0.0 /15 131,072 131,070 512
255.252.0.0 /14 262,144 262,142 1024
255.248.0.0 /13 524,288 524,286 2048
255.240.0.0 /12 1,048,576 1,048,574 4096
255.224.0.0 /11 2,097,152 2,097,150 8192
255.192.0.0 /10 4,194,304 4,194,302 16,384
255.128.0.0 /9 8,388,608 8,388,606 32,768
255.0.0.0 /8 16,777,216 16,777,214 65,536
254.0.0.0 /7 33,554,432 33,554,430 131,072
252.0.0.0 /6 67,108,864 67,108,862 262,144
248.0.0.0 /5 134,217,728 134,217,726 1,048,576
240.0.0.0 /4 268,435,456 268,435,454 2,097,152
224.0.0.0 /3 536,870,912 536,870,910 4,194,304
192.0.0.0 /2 1,073,741,824 1,073,741,822 8,388,608
128.0.0.0 /1 2,147,483,648 2,147,483,646 16,777,216
0.0.0.0 /0 4,294,967,296 4,294,967,294 33,554,432

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.