# subnetting

May 31st, 2010

I am comfortable in subnetting class C IP addresses.  How would you solve the following?

What is the last valid host on the subnetwork 172.29.80.0/20?

Thanks.

My above answer missed one point. Whenever you are asked to subnet, you must also consider number of host required within each subnet as

well. Like in my answer, the max host per subnet could only be 2. If this is your requirement then its ok, else, you have to also define how many host you need per subnet.

Its very simple.

If i have a /24 prefix length, which expands to 255.255.255.0, this means i can play only in last octet. Now remember one rule

1) There must be 2 bits at the min for the host portion when subnetting is being done. This is why 99% of the time you will see max subnet mask to be of /30

2) The above rule is sometimes ignored using a /31 mask, but its usage is not recommended.

So keeping the above rules in mind, how many bits are left for me to do any further subnetting with a /24 mask ?  8 bits (last octet) - 2 bits (above rule) = 6 bits

using the famous 2^n formula,  which becomes 2^6 = 64 subnets.

I hope it helps you.

Its very simple

1) First expand the prefix length to subnet mask.

/20 expands to 255.255.240.0

2) Any octet that contains value other then 0 or 255 is called interesting octet. In our case 3rd octet contains 240 so do the following

subtract interesting-octet value (240) from 256.

256 - 240 = 16.

Now start from 0 and add 16 till 256

0

.

.

.

16

.

.

.

32

.

.

.

48

.

.

.

64

.

.

.

80

.

.

.

96

.

.

.

(so on) till 256

Now the valid IP ranges are as follows

172.29.80.1<- First valid IP

172.29.80.2

.

.

.

172.29.95.254 <- Last valid IP

Now how did we get this ? Remember, the last valid IP is Just BEFORE the broadcast address of that subnet. In our case the subnet is 172.29.80.0/20, the broadcast address of this subnet is all ones in host portion. So the value will be 172.29.95.255 for broadcast address. Just minus 1 from the last octet and you get the last valid IP.

I have assumed you know how to do subnetting in binary.

Overall Rating: 5 (3 ratings)

## Replies

Jonn cos Tue, 06/01/2010 - 00:19

Its very simple

1) First expand the prefix length to subnet mask.

/20 expands to 255.255.240.0

2) Any octet that contains value other then 0 or 255 is called interesting octet. In our case 3rd octet contains 240 so do the following

subtract interesting-octet value (240) from 256.

256 - 240 = 16.

Now start from 0 and add 16 till 256

0

.

.

.

16

.

.

.

32

.

.

.

48

.

.

.

64

.

.

.

80

.

.

.

96

.

.

.

(so on) till 256

Now the valid IP ranges are as follows

172.29.80.1<- First valid IP

172.29.80.2

.

.

.

172.29.95.254 <- Last valid IP

Now how did we get this ? Remember, the last valid IP is Just BEFORE the broadcast address of that subnet. In our case the subnet is 172.29.80.0/20, the broadcast address of this subnet is all ones in host portion. So the value will be 172.29.95.255 for broadcast address. Just minus 1 from the last octet and you get the last valid IP.

I have assumed you know how to do subnetting in binary.

saidfarah Tue, 06/01/2010 - 23:03

You have a class B network with a /24 mask. How many usable subnets exist?

Jonn cos Wed, 06/02/2010 - 01:14

Its very simple.

If i have a /24 prefix length, which expands to 255.255.255.0, this means i can play only in last octet. Now remember one rule

1) There must be 2 bits at the min for the host portion when subnetting is being done. This is why 99% of the time you will see max subnet mask to be of /30

2) The above rule is sometimes ignored using a /31 mask, but its usage is not recommended.

So keeping the above rules in mind, how many bits are left for me to do any further subnetting with a /24 mask ?  8 bits (last octet) - 2 bits (above rule) = 6 bits

using the famous 2^n formula,  which becomes 2^6 = 64 subnets.

I hope it helps you.

Jonn cos Wed, 06/02/2010 - 01:20

My above answer missed one point. Whenever you are asked to subnet, you must also consider number of host required within each subnet as

well. Like in my answer, the max host per subnet could only be 2. If this is your requirement then its ok, else, you have to also define how many host you need per subnet.

saidfarah Wed, 06/02/2010 - 07:18

I am confused as to when you use the formula 2^bits for deriving the the number of subnets and when you use the formula (2^bits)-2 for the number of subnets.

Thanks.

saidfarah Wed, 06/02/2010 - 07:41

So the question arise is why do you have subnets if you are not going to  have any hosts? Thus you need to keep in mind to have a minimum 2 host inorder to have a subnet.

Thanks, I got it.