Easy Subnetting

You need 4 things to be able to determine the proper IPv4 subnet mask for a

given requirement.

1.An octet is 8 bits long. Know the bit value of each bit. This is easily done.

Write down the number 128.

128

Take half of 128 (64) . Write it next to 128

128 64

Take half of 64 (32) . Write it next to 64.

128 64 32

Take half of 32 (16) . Write it next to 32

128 64 32 16

Take half of 16 (8) . Write it next to 16.

128 64 32 16 8

Take half of 8 (4). Write it next to 8.

128 64 32 16 8 4

Take half of 4 (2) . Write it next to 4.

128 64 32 16 8 4 2

Take half of 2 (1) . Write it next to 2.

128 64 32 16 8 4 2 1

Write down these bit values. Each of these values has a bit position. 1 is

bit position1, 2 is bit position 2, 4 is bit position 3, etc. up to 128 being bit

position 8

2.Using the bit values from step 1, a shortcut for subnets can be created.

Write down bit position 8 (128).

128

Add 128 to bit position 7 (64) . Write it next to 128

128 192

Add 192 to bit position 6 (32). Write it next to 192.

128 192 224

Add 224 to bit position 5 (16). Write it next to 224

128 192 224 240

Add 240 to bit position 4 (8) Write it next to 240.

128 192 224 240 248

Add 248 to bit position 3 (4). Write it next to 248.

128 192 224 240 248 252

Add 252 to bit position 2 (2). Write it next to 252.

128 192 224 240 248 252 254

Add 254 to bit position 1 (1). Write it next to 254.

128 192 224 240 248 252 254 255

Write down this shortcut mask

 

3.Remember 2 to the nth -1 , where n is the number of bits. For example if

n =3, 2 to the 3rd -2 = 6. (2*2*2 =8, 8-2=6).

4.Class designations for network and host portions of the address.

xxxx = network portion yyyy = host portion

Class A = xxxx.yyyy.yyyy.yyyy Default subnet 255.0.0.0

Class B = xxxx.xxxx.yyyy.yyyy Default subnet 255.255.0.0

Class C = xxxx.xxxx.xxxx.yyyy Default subnet 255.255.255.0

 

Everything else can be derived from these three memory jogs. You need a little

bit of binary savvy, from here. In binary it is either on or off. Working from the

right using the bit values from step 1, it is not too tough. Binary 101, means bit

position1 (value 1) is on, bit position 2 (value 2) is off and bit position 3 (value 4)

is on, so binary 101 is the total of the bit position set on - 1 + 4 = 5. With this

elementary bit of binary lectureout of the way, let's move on.

Let's say you can't remember the address ranges for IP classes. You know that

ALL Class A IP addresses being with 0. Using the bit values as derived in step

1, bit position 8 (128) is zero. So the greatest value that can be derived is the

sum of bit values 1 - 7 , which is 127. So class A IP addresses are 1-127. You

know that ALL Class B IP addresses begin with 10. This means that the lowest

value is one where bit position 8 (128) is on and the rest of the bits are off. So

the begin address for Class B is 128. Bit position 7 MUST be a 0 (off), so if bit

positions 6 thru 1 are on, the total value of these bit position would be 63 (32 +

16 + 8 + 4 + 2 +1). Add this to bit position 8 (value 128) which must be on,

and you get 191. So, Class B IP addresses are 128-191. You know that ALL

Class C IP addresses begin with 110. This means that the lowest value is bit

position 8 (value 128) and it position 7 (value 64) are on and the rest of the bits

are off. So the begin address for Class C is 128+64 = 192. Bit position 6

MUST be a 0 (off), so if bit positions 5 thru 1 are on, the total value of these

positions would be 31 (16 + 8 + 4 + 2 + 1). Add this to the total of bit positions

8 and 7 (128 + 64 = 192) and you get 223. So, Class C IP addresses are

192-223.

Let’s say you need to apply a subnet mask to a Class B network which creates

20 subnets. First step is to figure out what 20 looks like in binary – 10100. This

requires 5 bits. Let’s braincheck this with number 3 from above. (2 to the nth

power - 2 ). In this case it is 2 to the 5th power –2, which is 2*2*2*2*2 – 2 =

32 –2 = 30. So five bits for the subnet mask allows 30 subnets. What about 2 to

the 4th power ? 2*2*2*2 -2 = 14 subets – not enough, we need 20. So 5 bits it

is for the subnet mask Use the shortcut mask created in step 2. Count over 5

positions from the left. That gives us 252. So the subnet mask in this case would

be 255.255.252.0. (don’t forget from step 4 the default subnet mask for Class B

address is 255.255.0.0, we replace the third octect to subnet the address). If we

use 5 bits of the 16 bits originally designated for the host portion of the address

to extend the subnet mask, that leaves 11 bits for the host portion. This means

that 2 to the 11th - 2 number of hosts (2046 hosts).

Let’s go the other way, and say we need to allow 500 hosts per subnet for a

Class B network. What subnet mask should we use? First represent 500 in

binary – 111110100. That’s 9 bits. So of the 16 bits originally allocated to the

host portion of a class B address, we need 9 of them to allow for at least 500

hosts. Braincheck – 2 to the 9th – 2 = 510 – that satisfies our requirement of

500 hosts. That leaves us 7 bits (16 – 9) available to assign to the subnet mask.

So once again if we use the shortcut mask created in step 2, we count over 7

positions from the left. That gives us 254. So the subnet mask in this case would

be 255.255.254.0.

The last bit of information we need is what subnet addresses are created ? Let’s

say we need 8 subnets for a Class B network. First step is like before, determine

what subnet mask to use. First step is to represent 8 in binary – 1000. Subnet

mask would be 255.255.248.0. Braincheck – 2 to the 4th – 2 = 14 subnets.

The next step is to determine what the interval is. Using the bit values as

determined in step 1, Count over 4 positions (the number of bits used for the

subnet mask) from the left gives us 16. This is the interval. Using this subnet

mask yields the following subnet ids :

0-15 16-31 32-47 48-63 64-79 80-95 96-111

112-127 128-143 144-159 160-175 176-191 192-207 208- 223

Always throw away the low and high address (0-15 invalid and 208-223

invalid). Given a Class B address 158.128.0.0, the first subnet created allow IP

addresses 158.128.16.1 – 158.128.31.254, the second subnet created allows

IP addresses 158.128.32.1 – 158.128.47.254, etc.