Canadian IT Professional Workshop

## The Art of IPv4 Networking and SubNetting

Takeaway- To get a good grasp of IPv4 networking concepts, including subnetting. I will be doing a brief overview of some important IPv4 concepts as well as problems and limitations with IPv4.

An IPv4 address is broken down from a single 32 bit binary number to four 8 bit octets and they are then usually presented in dotted decimal form. The reason that IPs are broken down like this is for ease of reading, after all 220.168.5.1 is much easier to read than 1101 1100.1010 1000.0000 0101.0000 0001 and even here I have made an attempt to make it more readable.

When working with binary numbers it is important to understand what the ones and zeros actually mean. Every one or zero actually represents a binary digit or bit. A bit can be turned on or off, hence the 0 or 1. Sometimes the bit maybe referred to as true or false, or yes or no. In either case, there is no grey area, either the bit is or it isn’t. It is important to understand this since each bit represents a different value based upon its position.

The bit on the far right represents 1, to the left of that the next bit represents 2 next one represents 4 then 8 and so on. It is important to note that these values are exponentials of 2.So, 21=2 22=4 23=8 24=16 and so on. Everything revolves around the magic number two (as a bit can be either on or off, two different and distinct states). It may be easier to visualize this in the following chart. Since we have not changed the first octet, that value will remain at 255 and since we know the value of 0 in binary we just have to convert 1110 0000 back to decimal. After doing so our new subnet mask would be

255.224.0.0

Now before we carry on, you must remember that you can only set a bit subnet mask in order from the left to the right, always taking a host bit never a network bit. So a subnet mask octet of 1100 000 is valid but a subnet mask of 1101 0000 would not be valid. If you attempted to enter that value (which is 208) Windows 7 would respond with the following message Now taking this a step further, you can see that there are only 8 possible non zero values for a subnet mask. They would be represented in the following chart You must remember, you must have a subnet mask when you configure a network adapter or IP device. Even though Windows 7 will provide a default subnet mask for you when you are configuring an adapter or IP device manually, you still have to have the subnet mask When we display the subnet in the form of 255.224.0.0 we are displaying in dotted decimal value, however the short form way of displaying this is by displaying the number of network bits after the IP address. So in this example, we had 8 bits already from the default subnet mask and we took an extra three from the host section giving us 11 total network bits. The way we would represent this would be 10.11.12.13 /11. This is called CIDR, prefix or slash notation. The list of CIDR notations are in the following table If you can’t remember the entire list then you should be at least aware of the class’s default, which should not be that hard as they increase by 8 bits each. If you want to memorize the list and be an absolute superstar when it comes to subnetting, remember there are only eight different non zero values. If you can memorize the octet values and the bits that correspond with that octet you will breeze through subnetting pretty fast.

It may be redundant but here is a list of the non-zero octet values and their corresponding bit values With this information, what is the dotted decimal subnet mask of a /19 subnet mask.

Since we know that we have to go from left to right, always taking from the host ID, we go back to our first known class which is Class B. Class B is /16 and to go to a /19 subnet we have to get 3 extra bits from the host ID, giving us 224. So the subnet mask would be 255.255.224.0. We get the 255.255 from the Class B since it is closest and then we get the 224 since it has 3 bits set within the octet

Here are a few more questions for you. Try and not use these charts if you can.

• What is the dotted decimal subnet mask of /22 ?
• What is the CIDR notation of the subnet mask of 255.255.248.0 ?
• What is the dotted decimal subnet mask of /12 ?
• What is the CIDR notation of the subnet mask of 255.255.255.224 ?
• What is the dotted decimal subnet mask of /30 ?
• What is the CIDR notation of the subnet mask of 255.255.248.192 ?

Answers-

The dotted decimal subnet mask of /22 is 255.255.252.0. Since we know we have to go back to the Class B network, the first two octets would be 255.255. Now we borrowed 6 bits and that would give us a value of 252. The last value would of course be zero.

The CIDR notation255.255.248.0 would be 16 network bits for the 255.255 and 5 more bits for the 248. That would give us a /21.

The dotted decimal value of /12 would be 255.240.0.0. Since we have the first 8 bits from the Class A network, we can see that we have 4 borrowed bits.

The CIDR notation of 225.225.225.224 is /27. Since we have 24 bits for the 255.255.255 and 3 bits for the /27.

The dotted decimal subnet mask of /30 would be 255.255.255.252. Since we have 24 bits from the Class C network giving us the 255.255.255 we see that the borrowed 6 bits gives us the .252.

255.255.248.192 is not a valid subnet mask since the bits that define the network ID must be continuous.  The mask represented in binary would be 1111 1111.1111 1111.1111 1000.1100 0000. This is clearly not a valid subnet mask at all.

When working with a network with custom subnets, the network is said to be classless. Remember the IP addresses don’t change at all, they still retain their classes, it is just how the network itself has been altered and is now referred to.

Now that you have the basis of subnetting down, you need to go to the next step in how many subnets are actually created. Since the whole purpose of subnetting is to break a network down into more manageable chunks, we need to figure out how many subnets are actually created when we apply our custom subnet mask.

To calculate how many subnets are created with a specified subnet mask, we first have to find out how many borrowed bits we have. To do this we take our CIDR notated subnet mask and subtract the classful mask from it. For example, suppose we had a subnet mask of /20. We know that we can only take bits from the host ID, never from the network ID, so we have to go back to the class on the left of the subnet mask.

In this case the default class would a B Class. Since a B Class has 16 bits we would take our subnet mask of /20 and subtract /16 from it which would give us 4 borrowed bits. The equation would be

subnet mask-clasful mask=borrowed bits (s)

Now we take our borrowed bits (s) and put them into the following formula to get the number of subnets that would be created.

2s=Subnets created.

However, some older network equipment will have trouble with the first and last subnet, so for those old routers and such the formula would be

2s-2=Subnets created.

However all new routers support the use of zero subnets so you should be good with the first formula, you should just be aware of any old equipment.

So in completing our example, since we have 4 borrowed bits, we would have 24 or 16 subnets created.

In our previous work, you have seen the magic number 2 and its exponential values; in the chart below detailing the subnets created most if not all of the numbers should be familiar to you. Now in I am allowed to digress a bit to something that has nothing even to do with networking at all, but it demonstrates the magical power of 2. If you had a computer with 8GB of ram, how much ram does it actually have? Answer- 8 192 000 000 Bytes of ram. You can see from this how the entire computer is based upon the principals that we are talking about.

Now if we get back to our example at hand, we now have created 16 subnets, but the next question is how many hosts are available in each subnet? With a Class B network we would have 65 534 hosts available. But since we have taken 4 bits from the host ID, we no longer have that many, we need to have a way to figure out how many hosts we have in each subnet. To do this we first have to determine how many host bits we have left. This is easily done since the length of the full length of the subnet mask is always 32 bits; we only need to subtract the how many network bits we have used in total. So the formula would be:

Number of host bits (h)= 32-CIDR notation subnet mask

In this example again it would be 32-20 which is 12 host bits (h). Now we must plug that value (h) into the following equation.

Number of Hosts=2h -2

And that would give us 212-2 which is 4092

One thing you have to remember when calculating subnets and hosts is that when working with subnets you must use the default subnet mask. When working with the number of hosts, the default subnet mask is absolutely meaningless to you. This is one area when working with subnets that will guarantee to mess up your work.

The following chart displays the number of available hosts per subnet. As you can see the chart is almost identical to the chart displaying the number of subnets created, in fact it would be identical if you were using old hardware and could not use the first and last subnet created.

For a new example, what would the subnet mask be if we needed to create 5 subnets for the network of 10.10.10.0?

Go backwards on our formula, 2s= Number of Subnets. Since we can’t possibly get an even 5 subnets we have to round up to the nearest power of 2 which in this case is 8. And to get to 8 we must use 3 bits. Now we go back to the first part of the formula subnet mask-clasful mask=borrowed bits (s).  Since we already know that 10.10.10.0 is a Class A Network with a default mask of 8 bits and that we borrowed 3 bits we have to add the two together and that would give use 11. So the answer would be

10.10.10.0 /11 or 255.224.0.0

Now if you had a network IP of 192.168.5.1 what would the subnet mask be if you want 32 hosts in each network?

First off, throw the IP and the class that comes with it in the garbage, they are absolutely trash and will only mean to trick you up. So what the question really should be is how to create a network with 32 hosts in it. It doesn’t matter what class the network is at all, the only thing that will change from class to class is the number of networks that would be available, not the number of hosts in each network.

So we go back to our formula Number of Hosts=2h-2. Since we need 32 hosts, we have to borrow 6 bits to give us 62 hosts since 5 host bits would only give us 32-2 or 30 hosts. So in further our example we need that last part of the formula which is Number of host bits (h)= 32-CIDR notation subnet mask.  So now we know that CIDR notation subnet mask=32-6 which is 26.  So our subnet mask must be 255.255.255.192 or IP/26.

Now for this last example, in a Class A network you would have 262 144 subnets generated, with a Class B network you would have 1024 subnets created and with a Class C network you would have 4 subnets created. But each with 62 hosts per subnet.

Now come the really important part, all through this exercise we have learned to create custom subnets based upon the actual number of subnets we needed and we also created subnet based on how many hosts we actually needed in each subnet. Now we have to identify and deploy these subnets properly. If you have a DHCP server you must make sure after all that it is going to give out the proper IP addresses in the proper subnet.

There are different ways to figure out the new subnets, but I am going to show you what I think is the easiest way. It doesn’t require you to convert anything to binary or compare any bits. What it will require you to do is have a dotted decimal subnet mask and a wee bit of imagination.

Now for this example I am going to use three different IPs

10.0.0.0                                                                172.16.0.0                                            192.168.1.0

As you can see each IP has a different class, one from A another from B and the last from C. Now I want to create a new subnet by borrowing 4 bits. That would give us the following new subnets

10.0.0.0/12                                                          172.16.0.0/20                                     192.168.1.0/28

Now we need to find out how many subnets and hosts we have. This is going to be relatively easy since we already have most of the information. The number of subnets we will have is 24=16. Remember since we are using 4 bits across all three IPs, the number of subnets will remain the same in this example; the number of hosts however will be dramatically different. Now we need to determine how many hosts we will have and that is you remember host bits(h)=32-CIDR notation subnet mask and then 2h-2 which will give us the following

10.0.0.0/12                                                          172.16.0.0/20                                     192.168.1.0/28

#of subnets-4                                                    #of subnets-4                                    #of subnets-4

#of hosts per subnet-1 048 574                  #of host per subnet-4094             # of hosts-14

Now what you could do is manually count from the start of the IP range until you have gone through your total number of hosts and mark off the subnets that way, but with Class A having more than a million hosts, it might take a while. The trick to this is to convert the CIDR notated subnet mask to dotted decimal, which would give us the following-

10.0.0.0                                                                172.16.0.0                                            192.168.1.0

255.240.0.0                                                         255.255.240.0                                     255.255.255.240

Now again since we have borrowed the same amount of bits we see a very similar subnet mask, and that is great, it is part of the example here.

Since we already know where the first subnet is, what we need to do if find where the second one starts and the rest is very easy.

What we need to do is subtract the modified octet in the subnet mask from the largest possible value an octet can represent, and that value is not 255. It is 256, since you must also include 0 as a value as well.

So for all the examples we would have 256-240 which gives us 16. Where we use this 16 depends on where the modified subnet octet was located. So now we can build our subnets as the following. This will work all the time, as long as you have the IP set point and the subnet mask, you can identify any and all subnets. You don’t even need to know how many subnets you will be creating or how many hosts you will have (though it always is nice to know). Just remember 256- the subnet octet in question will give you the starting point of the next subnet. Go back one IP and you have the ending for your subnet and you are good to go from there. You will be easily able to map out your entire network.

Just a few things to remember, there are two addresses which cannot be used. They are the first and the last IP with the subnet. So for the first subnet 10.0.0.0- 10.15.255.255, both the 10.0.0.0 and the 10.15.255.255 cannot be used since the first IP of every subnet is reserved for the ID and the last IP of every subnet is reserved for discovery.

Now just a few words about the downsides of subnetting, you properly already have figured it out. But you can waste an awful amount of IPs if you are not careful when setting up your network. In the one example where you needed only 5 subnets but where forced to create 8, that is a waste of 37.5% of your IPs. You really have to be careful and think things through properly.

Anyways this is the end of this part of networking and subnetting, I hope this was informative and helpful.

©2019 OTT-Over The Top Entries (RSS) and Comments (RSS)  Raindrops Theme