Friday, June 6, 2014

Subnetting made easy Part 2

Class A:
0.0.0.0     - 127.255.255.255 default subnet mask: 255.0.0.0 (or /8, 8 network bits and 24 host bits)
Class B:
128.0.0.0 - 191.255.255.255 default subnet mask: 255.255.0.0 (or /16, 16 network bits and 16 host bits)
Class C:
192.0.0.0 - 223.255.255.255 default subnet mask: 255.255.255.0 (or /24, 24 network bits and 8 host bits)
Class D: (Used for multicasting, not used for IP addressing)
224.0.0.0 - 239.255.255.255
Class E: (Unused)
240.0.0.0 - 255.255.255.255

Subnetting based on the number of hosts:

Example A:

Say that our assigned network is 213.213.213.0 and we need to divide it into networks that have 30 hosts each.

Let's consult a table for our decimal to binary conversion to find what 30 is in binary. We work with 8 bits and we start from 0, so we work from 20 to 27:

2726252423222120
1286432168421
00011110

That means we need 5 bits to represent number 30 (24 is the 5th bit, we start from 0) and therefore we need 5 bits for our hosts. 52=32, and the number of the actual usable hosts is 52-2=30.

213.213.213.0 is a Class C network.

Class C subnet mask: 255.255.255.0 (/24) or in binary:   11111111 11111111 11111111 00000000

Our subnet mask will be the default mask with the number of network bits that we will need to have in order to have the number of hosts we desire.

Class C subnet mask: 11111111 11111111 11111111 00000000
                                                                                  ^^^ we need 5 host bits, so we'll need to turn the last 5 bits to 0; the rest will be assigned as network bits by turning them to 1.                    

Our     subnet mask: 11111111 11111111 11111111 11100000
 In other words     :      255          255       255           224   (/27, since we have 27 network bits enabled)

So now, the number of our hosts will be the remaining host bits. In our case 32. The network bits are 3, so 23=8 networks.

The number of usable hosts in our network though will be the remaining host bits minus the network
address and the broadcast address, so 2 to the power of our remaining host bits minus 2.

So, in our case 25-2=32-2=30. We will have 30 hosts -exactly as many as we needed- in 8 networks.

A faster way to find this number is with what Cisco refers to as the interesting part. The interesting part is
the part of the subnet mask which is not 255. We subtract this number from 256 and that will be our IP address increment.

This in our case is the fourth part of the IP address. Also, In our case, 256-224=32.

So our first IP allocation will be 213.213.213.32. Just write the increments and fill the spaces in-between.

213.213.213.0
213.213.213.32
213.213.213.64
213.213.213.96
etc.
So our network is:

213.213.213.0 - 213.213.213.31
213.213.213.32 - 213.213.213.63
213.213.213.64 - 213.213.213.95
etc.
.....

Example B:

We are given the network 130.130.0.0 and we want to divide it into networks with 600 hosts each.

Let's consult a table for our decimal to binary conversion to find how 600 is represented:

The sum of our 8-bit table (128 to 1) amounts to 255 (obviously). 8 bits are not enough. We need more entries:

5122561286432168421
1001011000


So we need 10 bits for our hosts. 102-2=1024 number of hosts, 1022 usable hosts.

This is a Class B network so its network mask looks like this:

11111111 11111111 00000000 00000000


We need 10 host bits, so we'll need to turn the last 10 bits to 0; the rest will be assigned as network bits by turning them to 1. And now our netmask looks like this:

11111111 11111111 11111100 00000000 (/22)
   255          255           252          0

As we already said, we need 10 bits for our hosts. 102-2=1024 number of hosts, 1022 usable hosts.
The network bits are 6, so 26=64 networks.

256-252=4. So this is our network:

130.130.0.0
130.130.4.0
130.130.8.0
etc.

and our IP ranges are:

130.130.0.0 - 130.130.3.255
130.130.4.0 - 130.130.7.255
etc.
.....

Example C:

We have the network 10.0.0.0 and we want to split it into networks with 96 hosts each.

Let's consult a table for our decimal to binary conversion to find how 96 is represented:

12864.................
01.................

No need to calculate any more, we are sure that this is the correct bit, we go over after that
So we need 7 bits for our hosts. 27=128 hosts, 128-2=126 usable addresses.

This is a Class A network so its netmask looks like ths:

11111111 00000000 00000000 00000000

We need to have 7 host bits, so our netmask should look like this:

11111111 11111111 11111111 10000000 (/25)
   255           255         255         128

So 27=128 hosts, 128-2=126 usable addresses, 217=131072 networks.

256-128=128. Our IP ranges are:

10.0.0.0 - 10.0.0.127
10.0.0.128 - 10.0.0.255
10.0.1.0 - 10.0.1.127
etc.

Now that we've gone through the basics and learned how to subnet, we need to note:
It's always a good idea to add one when trying to subnet based on hosts just in case our number is on a binary calculation boundary (e.g. 128,64,32,16,8,4,2,1).

Let's go over an example again with our new method:

Say that our assigned network is 213.213.213.0 and we need to divide it into networks that have 32 hosts each.

We need to add one so instead of calculating for 32, we calculate for 32+1=33:

Let's consult a table for our decimal to binary conversion to find what 33 is in binary.

1286432168421
00100001

We need 6 bits to represent number 33. 62=36, and the number of the actual usable hosts is 62-2=34.

213.213.213.0 is a Class C network.

Class C subnet mask: 255.255.255.0 (/24) or in binary:   11111111 11111111 11111111 00000000

Our subnet mask will be the default mask with the number of network bits that we will need to have in order to have the number of hosts we desire.

Class C subnet mask: 11111111 11111111 11111111 00000000
                                                                                                     
Our subnet mask:       11111111 11111111 11111111 11000000
In other words:             255          255          255         192   (/26, since we have 26 network bits enabled)

The network bits are 2, so 22=4 networks.

The number of usable hosts in our network will be the remaining host bits minus the network address and the broadcast address, so 2 to the power of our remaining host bits minus 2. As calculated earlier, 62=36, and the number of the actual usable hosts is 62-2=34.


This in our case is the fourth part of the IP address. Also, In our case, 256-192=64.

So our first IP allocation will be 213.213.213.64. Just write the increments and fill the spaces in-between.

213.213.213.0
213.213.213.64
213.213.213.128
213.213.213.192

So our network is this:

213.213.213.0 - 213.213.213.63
213.213.213.64 - 213.213.213.127
213.213.213.128 - 213.213.213.191
213.213.213.192 - 213.213.213.255

If we had done the calculation without adding one, we would have provisioned for 30 hosts (5 bits,25=32,30 usable hosts)

No comments:

Post a Comment