  IP is the dominant network protocol in use today in both Local Area Networks (LANs) and on the Internet. However, IPv4 addressing is anything but simple. Too often, IP subnetting is a source of confusion even for experienced technicians. However, it is an inescapable fact that most networks will require subnetting for optimization and security purposes.

Learn how to work with subnets and TCP/IP networks

What are Subnets?

The practice of sub-dividing a network into multiple sub-networks is called subnetting. It is achieved by clever manipulation of the IP address and its corresponding subnet mask.

An IP address is in the format;

IP Address Range (N= Network, H = Host)

Class

 NNNNNNNN . HHHHHHHH . HHHHHHHH . HHHHHHHH

A

(/8) 255.0.0.0
 NNNNNNNN . NNNNNNNN . HHHHHHHH . HHHHHHHH

B

(/16) 255.255.0.0
NNNNNNNN.NNNNNNNN.NNNNNNNN.HHHHHHHH

C

(/24) 255.255.255.0

N/A

D & E

Multicast &reserved

In the table above, the IP address components are designated as network or host bits, the subnet mask designates the boundaries. For example, for a class A network the mask is an /8, a class B is a /16, and a class C is /24. These demarcations points are commonly represented by decimal notation such as 255.0.0.0, 255.255.0.0 or 255.255.255.0 either way they mark the boundaries of what is a network and what is a host.

So, how do professionals manage to calculate subnets and masks in their head? Well, they think in decimal, not binary. They do this by extending the subnet mask by borrowing host bits from the designated host range. For example, a single 192.168.16.0/24 address range can be split into two by extending the subnet mask by borrowing one bit, transforming the subnet mask from a /24 to a /25 or a 255.255.255.128 in decimal notation. The table below outlines the options achievable by borrowing host bits to extend the subnet mask.

 Subnet mask No of Subnets No of Hosts per subnet Remarks (/24) 255.255.255.0 1 254   (256 -2) Default (/25) 255.255.255.128 2 126   (128 -2) Large departments (/26) 255.255.255.192 4 62     (64 -2) Medium Large dept (/27) 255.255.255.224 8 30     (32 -2) Medium departments (/28) 255.255.255.240 16 14     (16 -2) Small departments (/29) 255.255.255.248 32 6       (8 -2) ADSL Connections (/30) 255.255.255.252 64 2       (4-2) WAN LINK / Point-to -Point

Regardless of what address range is used, class A, B or C, it is possible to use basic math to subnet. The individual subnets and hosts can be determined through two basic formulas.

1. Number of subnets = 2n where n is the number of bits borrowed to make the subnet mask
2. Number of hosts = 2(32 – n) – 2 where n is the number of bits in your subnet mask

For example, what subnet does the host IP 192.168.16.47/27 belong too?

The mask is a /27. So next demarcation boundary is 32, it is greater than boundary 24 but less than 32. Therefore by applying the formula,

Number of hosts = 2(32 – n) – 2 we can easily determine its subnet.

Explanation – to determine the number of hosts per subnet, the value of n is equal to the length of the subnet mask. In the example above, the formula is thirty-two (the class boundary) minus twenty-seven (the subnet mask) therefore (32 – 27) = 5. It follows that 25 = 32 which gives us our block size – the number of hosts per subnet. However, two addresses are unavailable for use as host addresses, namely the first and last addresses. The first address of a subnet identifies the subnet and the last indicates the subnet broadcast address, which is used to communicate with all hosts in that subnet, hence the -2 in the formula.

Now, it is simply a case of counting from zero upwards in the fourth octet using the previously determined host block size, which in this case is 32.

1st Subnet 192.168.16.0 – 192.168.16.31

2nd Subnet 192.168.16.32 – 192.168.16.63  (The host 192.168.16.47 belongs to this subnet)

Its subnet address is 192.168.16.32 and it broadcast address is 192.168.16.63, it is important to remember that a subnet always starts with an even number and the broadcast with an uneven number.

The rules apply not just to Class C addresses but to the other classes as well, here is an example of a Class B borrowing bits in the third octet.

What subnet does 172.16.116.4/19 belong too?

The mask is 19 so 24 is the closest boundary therefore (24 – 19) =5, so  2^5 = 32

Counting up from zero using the host block size of 32, but this time in the third octet, has 172.16.116.4/19 in the 4th subnet, it will have a subnet address of 172.16.96.0 and a broadcast address of 172.16.127.255

1st subnet 172.16.0.0

2nd subnet 172.16.32.0

3rd subnet 172.16.64.0

4th subnet 172.16.96.0 (172.16.116.4/19 belongs in this subnet)

5th subnet 172.16.128.0

How to Subnet Quickly and Efficiently like the Professionals

• The first step is to understand the relationship between the decimal to binary overlay, then think in decimal.
 128  64 32 16  8   4   2 0 0   0   0  0  0  0  0  0
• The second step is to remember the powers of 2
• The third is to remember the basic formulas

1.      Number of subnets = 2n where n is the number of bits borrowed to make the subnet mask

2.      Number of hosts = 2(32 – n) – 2 where n is the number of bits in your subnet mask

• Then remember that the more host bits are borrowed to make subnets the less hosts are available and vice versa.

These are the quick tips professionals use to calculate subnets, hosts and an IP address’ home network. If you wish to further investigate advanced IP design topics, then IP subnetting and address planning is just the start on the journey towards being an expert IP network designer.

Page Last Updated: April 2014

### Featured course

Networking Essentials

Last Updated March 2015

Bestseller
• 8 total hours
• 120 lectures
• All Levels
4.7 (577)

Gain the essential knowledge and skills required to configure, troubleshoot, manage and protect a data network. | By SONIC Performance Support - E-Learning Experts