Jun 26

IP Subnetting — let’s figure it out!

Tags:

———————————————————————
– OVERVIEW / THOUGHT PROCESS –
———————————————————————

IP address subnetting is actually pretty easy when you understand the individual components.  In this writing, I’ll attempt to give you the tools to understand those components so that you can take any subnetting scenario to a logical conclusion.  This will only be a novice view, so I would encourage you to do further research; however, this will give you a foundation upon which to build your knowledge.

Here are a few things that will be mentioned:

  • Subnet Explanation
  • Create a Custom subnet
  • Classes of Addresses
  • Scenario
  • Resources

Each of these items has a certain level of understanding that can be grasped by a novice network administrator.  The difficulty comes when you try to put all of these concepts together to get a big-picture understanding of what your network traffic is going to do.  Therefore, read and understand each of these components separately.  When you have an understanding of each component, then try to use the resources and scenarios to put it all together.

———————————————————————
– SUBNET EXPLANATION –
———————————————————————

Why do we subnet?  The answer is simple… so that we can have more IP addresses available to use.  When we don’t subnet and the natural network mask is used, it is called a ‘Classful Network’ which is generally deployed in our Small Office Home Office (SOHO) networks.  On large public networks (such as your internet provider’s network), without subnetting, we would run out of IP addresses as soon as we started creating the network, due to all of the users.  So subnetting gives us millions of options to form an efficient solution for the most complicated of networking problems.  But before we get to finding solutions, let’s start from the basics.

The zeroes and ones!  They are what the computer networks understand and, therefore, where we’ll start.  See if you can find the pattern to the following examples:

  • 11111111.11111111.11111111.00000000
  • 255.255.255.0
  • 192.168.1.0/24

Believe it or not, all of these examples reveal the same thing.  They reveal that the entire range of that IP address is available for use (‘Classful’).  So let’s look at the components.  11111111.11111111.11111111.00000000 is using an entire set of ones for each of the first three octets, which represents three octets worth of 255’s, which also corresponds to the total number of ones in that first example, represented at the end of the IP address using a slash (8 * 3 = 24).

So what happens if we want to do some subnetting?  Use the pattern that you just saw and compare it to this next pattern, which includes subnetting:

  • 11111111.11111111.11111111.11100000
  • 255.255.255.224
  • 192.168.1.0/27

If you don’t see the relationship, don’t worry about it.  I’ll reveal it to you now.  All those ones add up to 27 total, which is what you see after the IP address (/27).  Unfortunately, the .224 part will not be explained at this time, but it is directly related.  The reason I am not revealing this quite yet is because this is the part that confuses and frustrates new network administrators.  There will be a small bit of memorization required in order to completely understand that number, but it will be worth it, because that small bit of effort will make you a subnetting ninja!

Okay, so in that last example, we just added a few ones to the last octet… can we do that?  The answer is yes, but not without some consequences.  The technique of adding these ones to an octet is called ‘borrowing a bit,’ which turns a zero into a one.  The accepted consequence is the more bits you borrow, the more subnets you will have, which also means fewer IP addresses that will be available in your network.  But of course, that’s the whole point, isn’t it – to use what you need and make the rest available for something else.

Now let’s move on to the memorization thing I told you about.  Going back to our example, how did we get .224 at the end of our subnet mask?

BINARY 1 1 1 1 1 1 1 1
POWER OF 2 27 26 25 24 23 22 21 20
DECIMAL 128 64 32 16 8 4 2 1
TOTAL 128 192 224 240 248 252 254 255

As you can see, the bottom row reveals the number 224, which directly corresponds to the .224 at the end of our subnet mask in the example.  Before I show you how to ‘borrow a bit,’ I’m going to show you how to get the totals in the last row (if you haven’t already seen the pattern).  Starting from the left to the right, we see that the bottom row is increasing until it gets to 255, which we know well from our ‘Classful’ addresses.  We start with 128.  Then, simply add the next DECIMAL column to it, which will reveal 192 (128 + 64 = 192).  Then, simply add the next column of 32 to your total to reveal a 224.  It’s that simple.

I recommend memorizing this chart simply because having it right in front of you as a novice network administrator will vastly increase your time and efficiency when calculating your ranges.

So what now?  We have the chart memorized, but what can we do with it?  To answer this, we will reference our second example where we started subnetting above.  Do you remember counting the total number of ones for a sum of 27?  In the forth octet, we see that we ‘borrowed’ three total ones, which is why we came up with the .224 at the end of our subnet mask.  In the memorized chart, if we count from left to right on the TOTAL row, we will see that it takes us three total hops to get to the 224.  Those three hops correspond directly to the three ones that were borrowed in that forth octet above (255.255.255.11100000).

Now let’s move on to why this matters.  I mentioned before that the accepted consequence is the more bits you borrow means the more subnets you will have, which also means fewer IP addresses that will be available in your network.  Although it makes us efficient with our address usage, it also creates a bit of math for us.  Fortunately, the math is extremely simple.  I want you to memorize one more number.  Just the number 256.  That’s all!  Now, remembering how you got to .224 using the ‘borrow a bit’ method, simply subtract whatever you get from your borrowed bits from 256.  For instance, 256 – 224 = 32.  The 32 tells you how many IP addresses will be available in your subnet, depending on your class of address, which we’ll talk about in the next section.

Congratulations!  You just created a subnet!  But now that you have one, you also have to know what you can use.  When you create a subnet mask, you’ll need to know your network address range, the first usable address, the last usable address, and the broadcast address.  Although it would seem that we’ve given our subnet a certain amount of IP addresses, the truth is that only a certain number of them can actually be assigned to a device. And here’s why:

In our example above, we used 255.255.255.224, which further revealed that we had a total of 32 IP addresses that were usable.  So let’s fill in the blanks for each of the things that you need to know:

  • Network Address Range:  192.168.1.0 – 192.168.1.31
  • First Usable Address: 192.168.1.1
  • Last Usable Address:  192.168.1.30
  • Broadcast Address:  192.168.1.31

Since our subnet creates 32 addresses starting at zero, and the last one is unusable because it is our broadcast address, we can delineate that we have 30 total usable addresses in our first subnet.  Using 32 as our baseline, the networks would be listed as 192.168.1.0, then 192.168.1.32, then 192.168.1.64, and so on, keeping in mind that the first listed address in the range is not usable.  That’s why we list the first usable address as 192.168.1.1 instead of dot zero.  The next usable range, while still using the .224 in our example above, would be 192.168.1.33 – 192.168.1.62.  Remember, .32 defines the network, and .63 is our broadcast address.

So let’s go ahead and put this into practice by creating our first subnet.

———————————————————————
– CREATE A CUSTOM SUBNET –
———————————————————————

Using the IP address 203.175.10.0, create a custom subnet which separates each of the four networks by 64 addresses.

On a Classful address system, which would give us all 255 addresses (203.175.10.0 – 203.175.10.255), we would be using the subnet mask of 255.255.255.0.  In order to separate this one total network into four that use 64 addresses each, we must subnet… or ‘borrow a bit.’

Our Classful subnet mask looks like this:

  • 11111111.11111111.11111111.00000000
  • 255.255.255.0

When we start borrowing bits using the methods that we learned about above, it turns into this:

  • 11111111.11111111.11111111.10000000
  • 255.255.255.128

If we borrow one more (total of two), it looks like this:

  • 11111111.11111111.11111111.11000000
  • 255.255.255.192

We could continue to show the examples, but you can reference your memorized chart and see that .224 would come next.  Since we know through the referenced DECIMAL row that .224 would give us a separation of 32 addresses, we know that we’ve gone too far and have borrowed too many bits to fufill the requirements of this custom subnet.  Therefore, we’ll go with borrowing a total of two bits to give us a subnet mask of 255.255.255.192, which will give us our separation of 64, fulfilling the requirement.

Now, we must lay out each of the four networks.  Starting at zero, we will assign a total of 64 to each subnet:

  • 203.175.10.0
  • 203.175.10.64
  • 203.175.10.128
  • 203.175.10.192

Finally, we must fill in the blanks for the items described above.  We’ll start with our first network of 203.175.10.0:

  • Network Address Range:  203.175.10.0 – 203.175.10.63
  • First Usable Address:  203.175.10.1
  • Last Usable Address:  203.175.10.62
  • Broadcast Address:  203.175.10.63

Now we will move on to our second network of 203.175.10.64:

  • Network Address Range:  203.175.10.64 – 203.175.10.127
  • First Usable Addrss:  203.175.10.65
  • Last Usable Address:  203.175.10.126
  • Broadcast Address:  203.175.10.127

For our third network, we’ll start with 203.175.10.128:

  • Network Address Range:  203.175.10.128 – 203.175.10.191
  • First Usable Address:  203.175.10.129
  • Last Usable Address:  203.175.10.190
  • Broadcast Address:  203.175.10.191

And lastly, we will start with .192 but will have to stop at 255 because we are out of bits:

  • Network Address Range:  203.175.10.192 – 203.175.10.255
  • First Usable Address:  203.175.10.193
  • Last Usable Address:  203.175.10.254
  • Broadcast Address:  203.175.10.255

———————————————————————
– CLASSES OF ADDRESSES –
———————————————————————

Now that you know how a simple subnet works, you will need to know where you can apply these principles.  As mentioned many times, there are octets in each IP address.  Specifically, there are always four.  The first octet will allow you to determine which class of address you are using.

The Internet Corporation for Assigned Names and Numbers (ICANN) has set certain IP addresses aside for use with anything from the smallest of networks to the largest of networks.  In doing this, they have given classifications to each of these groups.  I will list them now, and then will explain what everything you see means:

  • CLASS A
    • 0.0.0.0 – 127.255.255.255
    • Default Mask:  255.0.0.0
    • Private Range:  10.0.0.0 – 10.255.255.255
    • Loopback Range:  127.0.0.0 – 127.255.255.255
  • CLASS B
    • 128.0.0.0 – 191.255.255.255
    • Default Mask:  255.255.0.0
    • Private Range:  172.16.0.0 – 172.31.255.255
    • APIPA Range:  169.254.0.0 – 169.254.255.255
  • CLASS C
    • 192.0.0.0 – 223.255.255.255
    • Default Mask:  255.255.255.0
    • Private Range:  192.168.0.0 – 192.168.255.255
  • CLASS D
    • 224.0.0.0 – 239.255.255.255
  • CLASS E
    • 240.0.0.0 – 255.255.255.255

CLASS A:  As you can see by the default mask, the CLASS A address is used for very large networks.  With a default mask of 255.0.0.0, it can fill up the first, second, third and fourth octets with up to 255 numbers apiece, which will allow for millions of IP address assignments.

CLASS B:  The class B range, on the other hand, has one less octet to work with.  The default mask of 255.255.0.0 only allows for the last three octets to be assigned numbers, which narrows your margin and lessens the amount of possible assigned addresses.

CLASS C:  The class C range is what will be seen in most Small Office Home Office (SOHO) networks because of the reduced amount of addresses available.  It holds a default mask of 255.255.255.0, which allows only the last two octets to be assigned numbers.

CLASS D:  Reserved for ‘multicast’ and should not be used on the internet.

CLASS E:  Generally reserved for research, but also should not be used on the internet.

PRIVATE RANGE:  Each class contains a private range of IP addresses that are not routable worldwide.  If a public router sees traffic from these IP ranges, they will drop the traffic instead of forwarding them.  Private ranges are used in the Small Office Home Office (SOHO) networks, which allows for maximum efficiency when creating an internal local area network.  You are still able to subnet with these private address ranges, and are encouraged to do so when building a SOHO network.

LOOPBACK RANGE:  This range, most commonly 127.0.0.1, is used to route packets or other electronic signals back to their originating points with no modifications.  As an example, if you can successfully ping your network card using 127.0.0.1, you know that your TCP/IP stack is working and your card is configured correctly to talk to other devices.  From a troubleshooting perspective, this eliminates your local hardware from being the problem, and you can move on to other media or suspected causes.

APIPA RANGE:  When a problem occurs while trying to gain an IP address from a Dynamic Host Configuration Protocol (DHCP) server, in most cases, your computer will still assign an IP address to your network card, allowing you to troubleshoot.  Automatic Private IP Addressing (APIPA) is a feature on many operating systems that allow this automatic assignment of addresses within the specified range.  If you see 169.254.x.x, you know that APIPA has occurred, and therefore you are not receiving an address from the DHCP server.

———————————————————————
– SCENARIO –
———————————————————————

Create a local network with the following criteria:

  • Begin with the Class C IP Address 203.175.10.0
  • SUBNET 1:  6 IP Addresses / 5 Nodes
  • SUBNET 2:  14 IP Addrsses / 12 Nodes
  • SUBNET 3:  30 IP Addresses / 28 Nodes

In this scenario, I am going to start from the third requirement and work my way to the first.  I generally like to go from large to small, so by starting with the requirement of 30 IP addresses, I can take out a chunk of the subnet first.

————————- SUBNET 3 ————————–

STEP 1 [Borrow The Bits]:  Start with 203.175.10.0 and create a subnet with at least 30 IP addresses.  The process for this should look familiar.  If you remember how we ‘borrowed bits’ before, you will know how to solve this portion of the scenario.  We begin with the Classful subnet mask of 255.255.255.0, which equates to 11111111.11111111.11111111.00000000.  Each time we borrow a bit, we refer to our memorized chart to see how many IP addresses are available.  If we borrow one bit, our subnet mask turns into 255.255.255.128, which equates to 11111111.11111111.11111111.10000000.  But 128 IP addresses are way too many for our requirement.  Therefore, we move onto borrowing another bit.  The next bit we borrow gives us a total of 64 IP addresses, which is still too many.  The next to the right is 32, which looks like it will fit nicely!

STEP 2 [Identify Usable Addresses]:  Using the memorized chart, we now know that our first subnet is going to be 255.255.255.224, which will give us 32 IP addresses.  Therefore, let’s identify our usable address range:

  • Network Address Range:  203.175.10.0 – 203.175.10.31
  • First Usable Address:  203.175.10.1
  • Last Usable Address:  203.175.10.30
  • Broadcast Address:  203.175.10.31

STEP 3 [The First Answer]:  203.175.10.0/27 is the answer because there were three borrowed bits to make our total amount of ones equal 27.  Always document your pieces of the solutions as you complete your work.

————————- SUBNET 2 ————————–

STEP 1 [Borrow The Bits]:  Now we need 14 IP addresses instead of 30.  Therefore, we’ll refer to our memorized chart to see what is required.  It just so happens that borrowing one more bit for a total of four gives us 16 more addresses.  Therefore, the new subnet will be 255.255.255.240, and the starting IP address will be 203.175.10.32.

STEP 2 [Identfiy Usable Addresses]:

  • Network Address Range:  203.175.10.32 – 203.175.10.47
  • First Usable Address:  203.175.10.33
  • Last Usable Address:  203.175.10.46
  • Broadcast Address:  203.175.10.47

STEP 3 [The Second Answer]:  203.175.10.32/28

————————- SUBNET 1 ————————–

STEP 1 [Borrow The Bits]:  Now we need 6 IP addresses instead of 14, and we’ll borrow bits to get them.  The next unit to the right on our memorized chart gives us 8 addresses and has a subnet of 248.

STEP 2 [Identify Usable Addresses]:

  • Network Address Range:  203.175.10.48 – 203.175.10.55
  • First Usable Address:  203.175.10.49
  • Last Usable Address:  203.175.10.54
  • Broadcast Address:  203.175.10.55

STEP 3 [The Third Answer]:  203.175.10.48/29

———————————————————————
– RESOURCES –
———————————————————————

If you’re like me, and you like to challenge yourself with things that you learn, check out this website for more scenarios.  (https://subnettingquestions.com/)

 

 

—————————————–

Always remember… WHAT IF AND WHY NOT?!?