Showing posts with label subnetting. Show all posts
Showing posts with label subnetting. Show all posts
Subnetting - Part 4: Route Summarization (2.10)

Subnetting - Part 4: Route Summarization (2.10)

In the final part of this series we are going to cover Route Summarization. If you havn't read the other parts of the series then we covered Standard Length Subnet Masks (SLSM), how to find all the subnets in a given network and prefix, and then we moved on to Variable Length Subnet Masks (VLSM). They are always worth a bit of a recap at any stage.

So route summarization is very similar to finding all the subnets within a network and a prefix. In fact much of the logic behind it is exactly the same.

Again we can do this through the binary method (which I actually think is easier for this) or the decimal method.

In the binary method we follow this process:

1. Write down the binary version of each subnet
2. Look to see where the numbers start to differ and draw a line down that portion.
3. Copy the bits that are the same into a new line and write 0s for the remaining bits. 
4. Convert the result from step 3 back into decimal.

We could use the same subnets as we used in part 2 of this series, but that would be a little too easy, so lets use (as we have done so far) the example from the Odom book and use the subnets of 172.31.20.0, 172.31.21.0, 172.31.22.0, and 172.31.23.0 with a /24 prefix.



Subnet Octet 1 Octet 2 Octet 3 Octet 4
172.31.20.0/24 10101100 00011111 00010100 00000000
172.31.21.0/24 10101100 00011111 00010101 00000000
172.31.22.0/24 10101100 00011111 00010110 00000000
172.31.23.0/24 10101100 00011111 00010111 00000000
Summary 10101100 00011111 00010100 00000000

So now we convert the summary address back into decimal and we have a prefix length of /22 and an address of 172.31.20.0

In the decimal method we do the following:

1. Count the number of subnets, then find the smallest value of y where 2y equals the number of subnets. So for four subnets 22 = 4, therefore y = 2
2. Subtract Y from the longest prefix length of the component subnets (with /24 subnets this would be 24 - 2 = 22)
3. Taking the lowest numeric subnet number in the component subnets, and then using it as an IP address calculate the subnet that this would live in (i.e. 172.31.20.0/22).
4. Repeat step 3 this time using the largest component subnet. If the resulting subnet matches step 3 then this is the best summarized route. (172.31.23.0 with a /22 gets us to 172.31.20.0/22)
5. If step 4 does not get the best result repeat steps 3 and 4 again, this time subtracting 1 from the previously used prefix length.

i do think that the binary method is clearly easier than the decimal method here, but then everyone is different and you may find that the decimal method works better for you.

And that wraps up this series on subnetting. Again I will be posting more examples in the near future.


Subnetting - Part 3: VLSM (2.10)

Subnetting - Part 3: VLSM (2.10)

In the third part of this series we will look at how we can take on subnet block and divide it into a range of subnets of differing size based on our requirements. If you need a refresher on the basics of SLSM then check out the first part of this series here.

Variable Length Subnet Masks (VLSM) is one of the more complicated aspects of subnetting to understand. With VLSM we take a network block and subdivide into a number of smaller networks.

We start off with the standard concepts for SLSM, and once we know the shortest prefix length and from there we can start to subdivide based on our requirements.

The process is as follows:

1: Find the shortest prefix length that will cover all of our required subnets.

2: Divide the available address block into prefixes of equal size based on step 1.

3: Knowing the subnets we need we allocate these to the beginning of the address block, leaving equal-sized address blocks at the end of the original block.

4: The first unallocated address block will then be subdivided by repeating steps 1 - 3, using the shortest requires prefix length for the remaining subnets.

5: If we need to allocate very small address blocks (say router to router i.e. /30) this should be done at the very end of the address range, which gives us some scope for future usage if requirements change later.

Confused yet? Imagine it as a funnel, with our assigned address block at the top, and as we assign subnets we start to reach the end of the funnel.

Again I will use the same IP's used in the Odom book, and if you havn't already got the book then you should go and buy it. 

So we have an assigned address range of 172.31.28.0/23. This will cover 172.31.28.0 to 172.31.29.255. Here we have one clearly defined summarized route, but our requirements are to split this as follows:

3 /25's
2 /27's
3 /30's

We can divide this into four blocks, which gives us four /25 subnets, and here we are using the same math as we used in part one with SLSM:

172.31.28.0/25 (172.31.28.1 - 172.31.28.128)
172.31.28.128/25 (172.31.28.129 - 172.31.28.254)
172.31.29.0/25 (172.31.29.1 - 172.31.29.128)
172.31.29.128/25 (172.31.29.129 - 172.31.29.254)

This takes care of the first requirement (3 lots of /25's). Now using the last subnet (172.31.29.128/25) we can start allocating the /27's.

These will be 

172.31.29.128/27
172.31.29.160/27
172.31.29.192/27
172.31.29.224/27

We stop at 172.31.29.224 because as we are incrementing by 32 the next subnet in the range would be 172.31.29.256 which is an invalid subnet. The first two subnets will take care of the second requirement (2 lots of /27's), and we have two blocks left over. As per step 5 we know that the the final requirement is for 3 lots of /30's so we leave the third subnet unallocated, which we can use at a later stage, instead we will focus on the 172.31.29.224/27 subnet instead.

The available address range for this subnet is 172.31.29.225 - 172.31.29.254. This can be divided into our /30's with a large number of blocks remaining, in fact we end up with eight blocks. A /30 subnet has four IPs in it, with two usable, so we just increment by 4 to find the underlying subnets.

We end up with the following subnets:

172.31.29.224/30
172.31.29.228/30
172.31.29.232/30
172.31.29.236/30
172.31.29.240/30
172.31.29.244/30
172.31.29.248/30
172.31.29.252/30

This gives us plenty of scope to have the final requirement (3 /30's) which will be the final three subnets in the list (remembering step 5 to use the end of the block, and leave the beginning of the block unallocated for future usage).

And there we have VLSM. It's really not that scary.

Our final post in this series will cover route summarization, and I will post some more examples of SLSM, VLSM, Route summarization and how to find all the subnets within a given network subnet in the resources section later.
Subnetting - Part 2: Finding all the subnets within a network (2.10)

Subnetting - Part 2: Finding all the subnets within a network (2.10)

Following on from part one of this series where we went through the basics of subnetting, and we are going to expand on that by finding all of the available subnets within an class and prefix.

Again this can be found either using the binary or decimal ways, and we are going to go through both here.

Finding all the subnets - Binary

1. Start by writing down the binary version of the classful network.
2. Separate the network and subnet parts of the number with one line, and the subnet and host parts with another line (I have actually bolded the number where the lines would be).
3. Calculate the number of subnets (including the zero-subnet and the broadcast subnet) using the method 2y where y is the number of subnet bits.
4. Write down y-1 copies of the binary network below the first one, leaving the subnet field blank.
5. Using the subnet field increment the values (001, 010, 011 etc)
6. Convert the binary numbers back to decimal

Again we are using the Odom book as the basis of this, so we are using the class B network 172.31.0.0, and a subnet mask of 255.255.224.0. we are using 3 subnet bits so there will be 23 subnets (if your algebra is as good as mine then this is the same as 2*2 = 4, 4*2 = 8).


Subnet Octet 1 Octet 2 Octet 3 Octet 4
Network number/Subnet 0 10101100 00011111 00000000 00000000
2nd Subnet 10101100 00011111 00100000 00000000
3rd Subnet 10101100 00011111 01000000 00000000
4th Subnet 10101100 00011111 01100000 00000000
5th Subnet 10101100 00011111 10000000 00000000
6th Subnet 10101100 00011111 10100000 00000000
7th Subnet 10101100 00011111 11000000 00000000
8th Subnet (Broadcast) 10101100 00011111 11100000 00000000

Converting these back into decimal we would see that the networks within this subnet are: 172.31.0.0, 172.31.32.0, 172.31.64.0, 172.31.96.0, 172.31.128.0, 172.31.160.0, 172.31.192.0 and 172.31.224.0.

Finding all the subnets - Decimal

The decimal way is very similar. As we saw with SLSM we look at the "interesting" octet. We know that 256-224 = 32 so we increment based on that.

So let's look at this in a bit more detail.

1. Start with the classful network number
2. For the first subnet number, copy the entire network number - this is subnet zero
3. Find the octet that contains the entire subnet field (the interesting octet)
4. find the magic number by subtracting this octet from 256
5. Copy down the non-interesting octets onto the next line as the next subnet number. There should only be one octet that's missing a value at this stage.
6. Start adding the magic number to the previous octet value, adding again and again as you go down the list
7. Repeat 5 and 6 until you get to 256. This subnet is not valid, so the one before this one will be the last valid one, and also the broadcast subnet.



Octet Comments
1 2 3 4
Network Number 172 31 0 0 Step 1
Mask 255 255 224 0 256-224=32
Subnet Zero 172 31 0 0 Step 2
1st Subnet 172 31 32 0 0+32 (Step 5 and 6)
2nd Subnet 172 31 64 0 32+32
3rd Subnet 172 31 96 0 64+32
4th Subnet 172 31 128 0 96+32
5th Subnet 172 31 160 0 128+32
6th Subnet 172 31 192 0 160+32
7th Subnet 172 31 224 0 192+32 (Broadcast subnet)
Invalid Subnet 172 31 256 0 Invalid

I'll post some more examples on the subnetting PDF that will follow the last part of this series shortly. But before that we have VLSM and Route Summarisation to complete.
Subnetting - Part 1: SLSM (2.10)

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.