Networking – How to you calculate IP address subnet ranges

ipip addressnetworkingsubnet

If you're given:

Number of needed subnets: 2   
Network Address: 195.223.50.0 

I can answer the following:

Address Class: C 
Default Subnet Mask: 255.255.255.0 
Custom Subnet Mask: 255.255.255.192 
Total number of subnets: 2^2 = 4 
Total number of host addresses: 2^6 (8-2 = 6) 
Number of usable addresses: 2^6 -2 
Number of bits borrowed: 2 

BUT…. if I'm asked….

What is the 3rd subnet range? 
What is the subnet number for the 2nd subnet? 
What is the subnet broadcast address for the 1st subnet? 
What are the assignable addresses for the 3rd subnet? 

How would I answer these… All I remember from the procedure is to look at the last number in the Custom subnet mask (192) and do 256 – 192 to get 64 and then use 64 to increment something. But I'm not sure what each question is asking. Please help, and explain step by step for each question.

Also, what would be different if I was faced with the Address Class of B in this situation?

Best Answer

TOOGAM has an excellent answer for this one.

However, I'll throw in my two cents, this is how I used to simplify it to wrap my mind around subnetting:

Look at IP addresses in binary. Each segment of an IP address is made up of 8 bits, or an octet, which means you have a working range of 0-255 because that's the range of numbers 8 bits can represent. Here are a couple of examples:

0.0.0.0 is 0000 0000.0000 0000.0000 0000.0000 0000  

and

192.168.1.0 is 1100 0000.1010 1000.0000 0001.0000 0000

You know that 192.168.1.0 is a class C address, right? In CIDR notation that means it's a /24 network and the mask is 255.255.255.0. What does this mean? Let's look at the binary again - the netmask in binary looks like this:

1111 1111.1111 1111.1111 1111.0000 0000

All the 1s are the bits of the actual address that are used to identify the network, while all the 0s are used to identify a specific host on the network. The /24 means that 24 bits are used to identify the network, go ahead and count them.

Note that every network has a network name (which is the FIRST address of the network, this is also your subnet number), and a broadcast address (which is the LAST address of the network). These two addresses are reserved, you cannot use them for hosts.

So let's say we want to split 192.168.1.0 into three subnets. We can't! Why? Let's work it out. If we borrow one bit, we can only have two subnets because one bit can only represent numbers 0-1.

Here's what I mean - if you want to borrow one bit, then the subnet mask becomes

255.255.255.128  

which, in binary, is

1111 1111.1111 1111.1111 1111.1000 0000
                              ^This is your borrowed bit right here

So now you have a /25 network. You're using 25 bits to represent your networks, and the remaining 7 bits to identify your hosts. (Note: When doing subnet calculations, it helps to stop thinking about the dots in the IP address and just deal with the binary. You'll see what I mean later.)

This only gives you two subnets,

         This part tells you which network it is!
                  vvvv vvvv vvvv vvvv vvvv vvvv v
192.168.1.0/25    1100 0000.1010 1000.0000 0001.0000 0000
                                                 ^^^ ^^^^
                   This part tells you which host it is!

and

          This part tells you which network it is!
                  vvvv vvvv vvvv vvvv vvvv vvvv v
192.168.1.128/25  1100 0000.1010 1000.0000 0001.1000 0000
                                                 ^^^ ^^^^
                   This part tells you which host it is!

The remaining 7 bits are reserved for identifying your hosts, so you can't use those. You have to borrow two bits instead, which can represent number 0-3. Like it or not, if you want three subnets, you have to split the network into four subnets at minimum.

So now you have a /26 network with these subnets:

192.168.1.0/26      1100 0000.1010 1000.0000 0001.0000 0000
192.168.1.64/26     1100 0000.1010 1000.0000 0001.0100 0000
192.168.1.128/26    1100 0000.1010 1000.0000 0001.1000 0000
192.168.1.192/26    1100 0000.1010 1000.0000 0001.1100 0000
                                                  ^^
        Look at these two bits! Watch how they go from 0 to 3 in binary.

To get the third network, all you have to do is look at your borrowed bits and make a 2, or "10" in binary. Why 2? Because we are counting from 0, not 1. In sequence, you have "0, 1, 2, 3", so the third network is "2".

You just slap this "10" into the borrowed bits and you can get the third network. For example, let's say I had an odd network like

 10.10.254.0/23 0000 1010.0000 1010.1111 1110.0000 0000

and I needed to split it into three subnets and find the third. In other words, I would need to make it into a /25 network because I need two borrowed bits at least. So now I have

10.10.254.0/25     0000 1010.0000 1010.1111 1110.0000 0000
10.10.254.128/25   0000 1010.0000 1010.1111 1110.1000 0000
10.10.255.0/25     0000 1010.0000 1010.1111 1111.0000 0000
10.10.255.128/25   0000 1010.0000 1010.1111 1111.1000 0000
                   Your borrowed bits are here ^ ^

It's super confusing if you look at the decimal IP addresses, isn't it? This is what I meant earlier when I said to work in binary and ignore the dots in the IP address when doing subnet calculations.

To get the broadcast address, simply fill the "host" part of your address with 1s. For example, the broadcast address of 192.168.1.128/26 is

   Remember, this is the "host" part of your address, the first
                                  26 bits represent the network
                                                   vv vvvv
192.168.1.191/26   1100 0000.1010 1000.0000 0001.1011 1111
       See how the host portion is filled with 1s? ^^ ^^^^

Likewise, to get the usable range, just start by putting a 1 in the last place of the network name to get the first usable address, then fill the "host" part with 1s and put a 0 in the last place of the network name to get the last usable address.

   Remember, this is the "host" part of your address, the first
   26 bits represent the network
                                vv vvvv
1100 0000.1010 1000.0000 0001.1000 0001      192.168.1.129/26
          First address: put a 1 here ^
1100 0000.1010 1000.0000 0001.1011 1110      192.168.1.190/26
                                      ^
Last address: fill the host part with 1s but put a 0 here

Of course, eventually you should learn how to do it like TOOGAM explained, but this might be helpful if you need to visualise the subnets.