What is IPv4 Subnetting?

Rashmi Bhardwaj | Blog,Protocol

What is IPv4 Subnetting

Although all IP addresses under IPv4 is going to be fully utilized in near future days, it will take a considerable period to transition the running networks on IP version 6. Consequently the concept of subnetting will remain at highest important place. With the advent of IP version 6, there will be no requirement to preserve the IP addresses by the means of subnetting but again it will take some years to get it into the market in full swing.

Understanding IPv4 Subnetting

In subnetting we borrow few bits of host part in to network part so that we can have many small subnets and few hosts in each subnet to preserve IP addresses. For example- If we take a normal IP address pool of class C, all the valid host IPs from to can be assigned to only one customer irrespective of the number of hosts required.

By subnetting we can divide this pool to into as many subnets as per the requirement of customers by assigning different subnet mask other than the default


Formula for calculation of number of valid subnets

Formula for calculation of number of valid subnets is 2n-2 where n is the number of borrowed bits. Number of valid hosts per subnet can be calculated by 2n-2 where n is the number of host bits left. Magic number or subnet width can be calculated by deducting the interesting octet from 256.

Here I am trying to make this grueling concept as easy as it can be.

Let’s start with subnet mask as it’s a crucial part of subnetting.

Subnet Mask

Subnet mask gives an idea that how many bits out of assigned 32 bits address are used to represent network and how many for hosts.


IP Address – Subnet mask- (In VLSM it can be written as

Here 29 bits are assigned for the network part and only 3 bits are representing the host part.


The numeral value of 248 in the last octet of the IP address concludes that first 5 bits are “on” and so giving a numeral value of 248(i.e. 128+64+32+16+8=248). All the remaining “off” bits is used for the host part.

Note: In calculation of subnet mask, if a bit is “on” then its corresponding decimal number is added and in case of “off” state it’s not added. So the numeral values (i.e. 4, 2 & 1) of 6th, 7th & 8th bit are not added.

Examples of subnetting

(1) Take a Class C IP pool or of class C. Here we have borrowed 2 bits from host part as default bits for network in class C is 24 bits (i.e.

By formula, the number of valid subnets is 22-2=2.

The number of valid hosts in each subnet is 26-2=62 as first IP address is fixed for network address and last IP is for broadcast address.

Magic number=256-192=64. This tells us that what should be the gap in two consecutive subnets.


In first subnet the PCs can be assigned any IP from to

Note: Here the interesting octet is the fourth octet as it has subnet mask (i.e. 192) rather than 255. So we see no changes in 200.10.5.

Practical benefit:-If two customers come to a provider with a demand of 60 hosts IPs each, we can assign to first & to second. Without subnetting we would have to assign the entire pool of to one and 200.10.x.0/24 to other and it would be a loss of more than 200 IPs.

(2) Take IP pool or of class C. Here 5 bits are borrowed from host part.

Number of valid subnets=2-2 = 30

Number of valid hosts per subnets=2– 2=6

Magic number=256-248=8


(3) Take IP pool or of class B. As the default subnet mask of class B is (or /16) so the interesting octet here is the third octet which is 224. Hence all the subnets will have 160.40 parts common. Here we have borrowed 3 bits from host part.

Number of valid subnets=23-2=6

Number of valid hosts per subnet=213-2=8190

Magic number=256-224=32


(4) Take IP pool or Here 4 bits from host bits are borrowed and interesting octet is third octet. Means all subnets will have 130.6 parts common.

Number of valid subnets=24-2=14

Number of valid hosts per subnet=212 -2=4094

Magic number=256-240=16

(5) Take an IP pool of class A or Here 3 bits are borrowed as class A has default subnet mask of Class A gives the maximum number of valid host IPs.

Number of valid subnets=23-2=6

Number of valid hosts per subnets=221-2=2097150

Magic number = 256-224=32ipv4-subnetting

(6) Take another class A IP pool or (We are using this for one of our cream customerJ). Here 16 bits are borrowed from host part in to network part.

Number of valid subnets=216-2=65534

Number of valid hosts per subnet=28-2=254

Magic number=256-255=1 (Here interesting octet is both second & third octet but addresses start filling from the third octet first)

Note: By using “ip subnet-zero” command in global configuration mode we can use the first and last subnets also which we didn’t use in above examples. With “ip subnet-zero” command the number of subnets is 2n rather than 2n-2 but there is no change in the formula of valid hosts.

Continue Reading:

Meaning of Ping Response for IPv4 Address

IPv4 vs IPv6


Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart