Simply Subnetting

By StealthNo Comments

Years ago in college I learned a very simple way to calculate subnets. I had since forgotten this method, but have recently been re-acquainted with it. This method uses the binary representation of the subnet mask to determine the number of hosts per subnet, in turn giving you the number of possible networks and host ranges.

The Basics

The first thing to do would be to get your subnet mask and convert it to binary. For this, there are only 6 binary numbers you need to remember: 128, 192, 224, 240, 248, 252, and 254. These numbers are represented in binary as (in order): 10000000, 11000000, 11100000, 11110000, 11111000, 11111100, and 11111110. I’m sure you’ll immediately notice a pattern here, which is that subnet mask numbers consist of one half 1’s and the other half 0’s. The part that is all 1’s becomes your network bits, and the part that is all 0’s becomes your host bits. This same rule applies to class A, B, and C networks.

Taking the mask of 255.255.255.252, we can get the binary representation of 1111111.11111111.11111111.11111100. During this part we’ll only need to work with the bold parts. We now have 6 network bits (counting the 1’s), and 2 host bits (counting the 0’s). We can now use this information to calculate our total networks and addresses per network. The simplest way to do this would be to take 2, and give it an exponent of the number of bits we have. Alternatively, you can count in powers of 2, by starting with 1 and doubling your number each count: 1, 2, 4, 8, 16, 32, 64, 128, 256, etc..

The example using 255.255.255.252 gives us 26 networks (64), and 22 (4) addresses per network.

As for network hosts, you will always need to subtract 2 from the total number of networks. This is because the first address is the network ID, and the last address is for broadcasts. Both addresses cannot be used to hosts. Referring again to 255.255.255.252, we have 4 addresses per network. Given the IP address of 192.168.1.x, the first network will be 192.168.1.0~192.168.1.3. The .0 will be this network’s ID, .3 will be this network’s broadcast. This leaves addresses .1 and .2 usable for host addresses.

CIDR Masks

A CIDR mask is a notation at the end of the IP address indicating the number of network bits in a subnet mask. A CIDR notation looks like 192.168.1.2/30 Every subnet mask has a total of 32 bits which are divided up into the 4 octets you’re familiar with. Let’s break down the previous example of /30 at the end of our address. Since the number indicates the number of network bits, we know this has 30 network bits and (32 – 30) host bits. This gives us a result of 11111111.11111111.11111111.11111100. Taking the last octet on that (11111100), we can then determine the number of networks and addresses as we did above. As mentioned above, this also applies to A and B network classes as well.

Making it a Little Easier

Generally you don’t need to know subnetting unless you’re going to be tested on your subnetting skill set. To make things easier, you can refer to this table for the basics.

 CIDR Bits  Addresses per Network
 Subnet  Networks  A  B  C  C  B  A
128 2 9 17 25 128 32768 8388544
192 4 10 18 26 64 16384 4194272
224 8 11 19 27 32 8192 2097136
240 16 12 20 28 16 4096 1048568
248 32 13 21 29 8 2048 524284
252 64 14 22 30 4 1024 262144
254 128 15 23 31 N/A 512 131072

This table gives you what needs to be known for basic subnetting. As before you should notice a pattern with the information on this table. You’ll also notice that some numbers don’t appear, such as 256 and 1024. They do not appear because they are standard networks for classes A, B and C.

Also note this table has addresses per network. To get the number of usable hosts you must subtract 2.

Things to Remember

This post only covers the basics of figuring subnet masks. There are other things that can further complicate and confuse subnetting, such as classful routing. If you’re new to subnetting, I do recommend using a subnet calculator to confirm your calculations until you’re comfortable with doing the calculations.

The Internets

Leave your Comment

Your email address will not be published. Required fields are marked *


three + = 11

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Blue Taste Theme created by Jabox