Subnetting - Part 1: SLSM (2.10)


Subnetting is (well to me at least) in the same vein as death and taxes, horrible but unavoidable. But as part of the CCIE exams it's an essential thing to learn and understand. Specifically the chances of having to work out what subnet an address is in, or whether it could overlap with another range, or to subdivide a subnet into more networks (VLSM), or to make our routing tables easier with route summarisation are all possible areas we will face in both of the exams.

In the first part I am going to to cover Standard Length Subnet Masks (SLSM) which will give us a nice understanding for the harder topics, which are Variable Length Subnet Masks (VLSM) and route summarization.

Both the CCNA and CCNP require an understanding of subnetting, but if you are anything like me, then a refresher is certainly in order.

So lets review the basics of what a subnet is.

A subnet is a range of IP addresses, it has the subnet number which is the entire range (like 192.168.1.0, or 10.0.0.0), then the range of addresses that are usable, which is one greater than the subnet address and one less than the broadcast address i.e. 192.168.1.1 through to 192.168.1.254 (if a standard class-C subnet mask is being used). Then lastly we have the broadcast address which is the highest number in the range.(i.e. 192.168.1.255).

So the starting point is to work out the subnet number.

Working out the subnet number

We can get the subnet number in two different ways, either converting to and from binary, or using the decimal method.

In the binary method we convert the IP address into the corresponding 1's and 0's and then perform a bitwise Boolean AND between the IP address and the mask.

In a Bitwise Boolean AND we place the binary numbers for the IP address and the subnet on top of each other and we AND the two bits, if both are 1 then the result is 1, if not then the result is 0.

So to start we convert the number into binary. I am using the same numbers as found in the excellent Odom book - each octet is broken down as follows:

Bit placement
128
64
32
16
8
4
2
1
172
1
0
1
0
1
1
0
0
31
0
0
0
1
1
1
1
1
103
0
1
1
0
0
1
1
1
41
0
0
1
0
1
0
0
1

So now we can see that that the IP address 172.31.103.41 converted into binary is:
 10101100 00011111 01100111 00101001.
We work out the subnet mask (here its a /24 or 255.255.255.0 subnet) in a similar way:



Bit placement
128
64
32
16
8
4
2
1
255
1
1
1
1
1
1
1
1
255
1
1
1
1
1
1
1
1
255
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0

And then we place these two numbers on top of each other and do the Boolean AND:



Octet 1
Octet 2
Octet 3
Octet 4
172.31.103.41
10101100
00011111
01100111
00101001
255.255.255.0
11111111
11111111
11111111
00000000
Result of AND
10101100
00011111
01100111
00000000
Broadcast
10101100
00011111
01100111
11111111

To get the broadcast address we now know the subnet mask address and we look at the interesting octet of the mask, in the case of the /24 subnet we are using it's the final octet because its all 0's.

For all the octets to the left of the interesting octet we copy down the same numbers as the subnet. For the remaining numbers we write down 1's.

So in the example above we have a subnet mask that is:
11111111 11111111 11111111 0000 0000
The broadcast would therefore be the first three octets of the subnet (the Result of the AND) and then all 1's:
10101100 00011111 01100111 11111111

Converting this back into decimal gives a subnet address of 172.31.103.0 and a broadcast of 172.31.103.255.

Now if we have a slightly harder subnet, such as 255.255.252.0 the theory is the same


Octet 1
Octet 2
Octet 3
Octet 4
172.31.103.41
10101100
00011111
01100111
00101001
255.255.252.0
11111111
11111111
11111100
00000000
Result of AND
10101100
00011111
01100100
00000000
Broadcast
10101100
00011111
01100111
11111111

In this example the subnet is 172.31.100.0 and the broadcast is 172.31.103.255.

We can do this in decimal using the following format:

Find the mask octets of 255 and copy down the same octets from the IP address.
Find the mask octets of 0 and write down 0s for the same octets.
If there is an octet that has not been filled in then that octet is the interesting octet. Find the subnet mask's value in the interesting octet and subtract it from 256.
Find the integer multiple of the result from step 3 that is closest to, but not larger than the interesting octets number:


Octet 1 Octet 2 Octet 3 Octet 4
Address 172 31 103 41
Mask 255 255 252 0
Steps 1 & 2 172 31
0
Subnet 172 31 100 0


So the magic number would be 265 - 252 = 4. 100 is the multiple of 4 that is closest to, but not greater than 103.


The broadcast calculation in decimal would be to start with the interesting octet (step 1&2) - the one that does not have 0 or 255 (the third octet in the example above). For octets to the left copy down the subnet address octet's numbers (step 3). For octets to the right write down 255 (step 4).

So so far we would have 172 in the first octet, 31 in the second octet and 255 in the fourth octet.

Next, take the interesting octet and subtract it from 256 to get the "magic" number.
Finally take the subnet number's interesting octet and add on the magic number, and then subtract 1.

In the example above the broadcast addresses third octet would be 256 - 252 (the interesting octet taken away from 256) which equals 4, which is then added to the subnet addresses third octet, which takes us to 104, and then finally we subtract 1. This leaves out third octet as 103, and the final broadcast address is 172.31.103.255:

Octet 1 Octet 2 Octet 3 Octet 4
Subnet 172 31 100 0
Mask 255 255 252 0
Steps 1 - 4 172 31
255
Broadcast 172 31 100 0


I hope that this has been useful so far. Under resources I will add a PDF of this page, along with more examples.

In another post we will look at how we can find all the subnets within a network.

CCIE #49337, author of CCNA and Beyond, BGP for Cisco Networks, MPLS for Cisco Networks, VPNs and NAT for Cisco Networks.

Related Posts

Previous
Next Post »