A comprehensive guide to understanding IP subnetting

Subnetting is the process of dividing larger network into smaller, manageable segments. In IP subnetting, every segment is isolated, making it difficult for intruders to access the entire network, thereby enhancing security. IP subnetting also reduces broadcast traffic and congestion in the network, improving the performance of the network. Therefore, managing a smaller network is more efficient as it is easier to focus on smaller segments rather than the entire network. Apart from improved security and efficiency, there are several reasons why IP subnetting is effective for networks. In this page, we will explore what an IP subnet is, the basics of IP subnetting, various subnetting techniques, how to calculate a subnet, and best practices.

Understanding the basics: What is an IP?

Knowing what an IP address is and its different classes will helps us understand subnets and subnetting easily.

IP address is a unique identifier assigned to every device that connects to the internet. Communication over the internet uses the Internet Protocol (IP), where data is transmitted from the source device to the destination device using the IP address of each device as a reference.

There are two types of IP addresses - IPv4 and IPv6.

IPv4 (Internet Protocol version 4):

IPv4 uses a 32-bit format, where each bit can either be a 0 or 1, resulting in approximately 4.3 billion possible combinations (2^32). An IPv4 address is represented by four octets separated by periods (e.g., 192.168.1.1). Each octet can represent a value between 0 and 256. The reason behind this is, each octet is 8 bits long, hence each octet can have 2^8 different values i.e between 0 and 256.

For example, the IP address 192.168.1.1 is represented in binary as 11000000.10101000.00000001.00000001.

A basic understanding of the decimal and binary number system is essential to understand IP addresses more accurately.

In the decimal number system, each number represents a number from 0 to 9 with a base of 10 i.e each number in the decimal number system has a place value like 1's place, 10's place, 100's place and so on.

For example: 129 is calculated as

1x100 + 2x10 + 1x9 = 129

However, in the binary number system, each number is either 1 or 0 with a base of 2 i.e each number in the binary number system has a place value like 1's, 2's, 4's place and so on.

Let's consider the same example, 129. In binary, 129 is 10000001.

1x128 + 0x64 + 0x32 + 0x16 + 0x8 + 0x4 + 0x2 + 1x1 = 129

IPs are converted from binary to decimal for ease of human readability. Now, let's gain an understanding about IPv6.

IPv6 (Internet Protocol version 6):

IPv6 uses 128-bit format, resulting in about 340 undecillion possible combinations. Realistically, every person on Earth can own up to 4 x 10^28 and we will still not run out of IPs. An IPv6 address is represented in hexadecimal format, a combination of numbers and alphabets, and are separated by collans (eg: 2001:0db8:85a3:0000:0000:8a2e:0370:7334)

Unlike IPv4 addresses, IPv6 uses a combination of alphabets and numbers; it is better read in its original hexa-decimal format rather than converting it from any other number system.

Now that we understood the different versions of IPs, here's a snippet of different classes of IPs and its purpose.

Since IPv4 is widely used and has distinct address classes, unlike IPv6, which doesn't use classes, it's important to understand the various IP address classes in IPv4.

To accommodate different network sizes and types, there are various classes of IPs. IP addresses are divided into 2 parts: the network prefix and the host identifier. The network portion helps identify the specific network, and the host identifier helps identify specific devices within the network.

Different classes of IPv4

Class A:

  • Range: 0.0.0.0 to 127.255.255.255
  • Example: 10.0.0.1
  • Network portion in the example: 10
  • Host portion in the example: 0.0.1
  • Purpose: Used in large networks.

Class B:

  • Range: 128.0.0.0 to 191.255.255.255
  • Example: 172.16.5.10
  • Network portion in the example: 172.16
  • Host portion in the example: 5.10
  • Purpose: Used in medium-sized networks.

Class C:

  • Range: 192.0.0.0 to 223.255.255.255
  • Example: 192.168.1.25
  • Network portion in the example: 192.168.1
  • Host portion in the example: 25
  • Purpose: Used in small networks.

Class D:

  • Range: 224.0.0.0 to 239.255.255.255
  • Example: 224.0.0.1
  • Network portion in the example: 224.0.0
  • Host portion in the example: They are used for multicast groups and not for individual hosts. Hence, the host portion is not applicable.
  • Purpose: Used in multicast groups

Class E:

  • Range: 240.0.0.0 to 255.255.255.255
  • Example: 240.0.0.1
  • Network portion in the example: 240.0.0
  • Host portion in the example: They are used for experimental purposes and not for devices. Hence, the host portion is not applicable.
  • Purpose: Used for experimental purposes

Let us understand IP subnetting in detail.

Fundamentals: Subnetting 101

What is subnetting?

As noted earlier, subnetting is the process of segmenting a larger network into smaller networks. The single, large IP network is divided into multiple sub-networks using a subnet mask where an IP address is separated into its network entity and host identifier entity.

What is a subnet mask and how does it divide an IP into its network and host components?

Subnet mask:

A subnet mask is structured very much similar to an IP address, but it is used only within a network, for internal purposes. In a subnet mask, each octet represents a part of the mask. Subnet masks are used to mask the IPs to determine which part of the IP denotes the network and which part denotes the host part.

Basically, a subnet mask helps users determine which subnet an IP address belongs to.

Let's understand how subnet masks are calculated.

The first step is to understand your network's needs. You should first determine how your network should be subnetted i.e if you want fewer IPs per subnet with lots of subnets or lots of IPs per subnet with few subnets. Yeah, you need to read that again for better understanding.

Once you have clarity on this, you can get started with subnet calculation right away.

Ground rule:

  • The formula to calculate the number of hosts is 2^h - 2, where h is the number of 0s in the host part, when the subnet mask is converted to binary.
  • The formula to calculate the number of subnets is 2^s, where s is the number of 1s added to the host part, when the subnet mask is converted to binary.
  • Adding 1s to the subnet mask results in fewer hosts per network but increases the number of network subnets.
  • Conversely, removing 1s from the subnet mask allows for more hosts per network but reduces the number of network subnets.

If you are wondering why, here is the explanation.

255.255.0.0 converted to binary is 11111111.11111111.00000000.00000000

In Class B, 11111111.11111111 is the network part and 00000000.00000000 is the host part. Introducing 1s to the host part (00000000.00000000) reduces the ability of creating more hosts. Hence, adding 1s increases the number of subnets but reduces the number of hosts within the subnet.

On the other hand, removing 1s from the subnet i.e network part (11111111.11111111) reduces the ability of creating more subnets. Hence, removing 1s increases the number of hosts but reduces the number of subnets within the network.

Note: The IPs and the subnet mask we will be taking into consideration throughout will be of Class B. The most commonly used subnet mask in Class B is 255.255.0.0. Let's consider the same. As noted earlier, Class B ranges from 128.0.0.0 to 191.255.255.255.

Calculating the subnet mask based on the required number of hosts and subnets

Case 1:

  • Subnet Mask: 255.255.0.0 (default)
  • Conversion to binary: 11111111.11111111.00000000.00000000
  • Number of hosts: 2^16 - 2 = 65,534
  • Number of subnets: 2^0 = 1 (no 1s are introduced into the host part)

With this subnet mask, you can have only one subnet, accommodating 65,534 hosts. This is the maximum number of hosts that a subnet can have in class B.

Case 2:

  • Subnet Mask: 255.255.128.0
  • Conversion to binary: 11111111.11111111.10000000.00000000
  • Number of hosts: 2^15 - 2 = 32,766
  • Number of subnets: 2^1 = 2

With this subnet mask, you can have 2 subnets accommodating 32,766 hosts, each subnet.

Case 3:

  • Subnet Mask: 255.255.192.0
  • Conversion to binary: 11111111.11111111.11000000.00000000
  • Number of hosts: 2^14 - 2 = 16,382
  • Number of subnets: 2^2 = 4

With this subnet mask, you can have 4 subnets accommodating 16,382 hosts, each subnet.

Case 4:

  • Subnet Mask: 255.255.224.0
  • Conversion to binary: 11111111.11111111.11100000.00000000
  • Number of hosts: 2^13 - 2 = 8,190
  • Number of subnets: 2^3 = 8

With this subnet mask, you can have 8 subnets accommodating 8,190 hosts, each subnet.

Case 5:

  • Subnet Mask: 255.255.240.0
  • Conversion to binary: 11111111.11111111.11110000.00000000
  • Number of hosts: 2^12 - 2 = 4,094
  • Number of subnets: 2^4 = 16

With this subnet mask, you can have 16 subnets accommodating 4,094 hosts, each subnet.

Case 6:

  • Subnet Mask: 255.255.248.0
  • Conversion to binary: 11111111.11111111.11111000.00000000
  • Number of hosts: 2^11 - 2 = 2,046
  • Number of subnets: 2^5 = 32

With this subnet mask, you can have 32 subnets accommodating 2,046 hosts, each subnet.

Case 7:

  • Subnet Mask: 255.255.252.0
  • Conversion to binary: 11111111.11111111.11111100.00000000
  • Number of hosts: 2^10 - 2 = 1,022
  • Number of subnets: 2^6 = 64

With this subnet mask, you can have 64 subnets accommodating 1,022 hosts, each subnet.

Case 8:

  • Subnet Mask: 255.255.254.0
  • Conversion to binary: 11111111.11111111.11111110.00000000
  • Number of hosts: 2^9 - 2 = 510
  • Number of subnets: 2^7 = 128

With this subnet mask, you can have 128 subnets accommodating 510 hosts, each subnet.

Case 9:

  • Subnet Mask: 255.255.255.0
  • Conversion to binary: 11111111.11111111.11111111.00000000
  • Number of hosts: 2^8 - 2 = 254
  • Number of subnets: 2^8 = 256

With this subnet mask, you can have 256 subnets accommodating 254 hosts, each subnet.

This makes it evident that reducing the 1s in the network portion (can be realized by observing the binary conversion from case 9 to case 1) will increase the number of hosts within a subnet.

Subnet Mask Table

Subnet Mask in Decimal Subnet Mask in Binary No of Subnets
[Formula: 2^s]
No of Hosts
[Formula: 2^h - 2]
255.255.0.0 11111111.11111111.00000000.00000000 1 65,534
255.255.128.0 11111111.11111111.10000000.00000000 2 32,766
255.255.192.0 11111111.11111111.11000000.00000000 4 16,382
255.255.224.0 11111111.11111111.11100000.00000000 8 8,190
255.255.240.0 11111111.11111111.11110000.00000000 16 4,094
255.255.248.0 11111111.11111111.11111000.00000000 32 2,046
255.255.252.0 11111111.11111111.11111100.00000000 64 1,022
255.255.254.0 11111111.11111111.11111110.00000000 128 510
255.255.255.0 11111111.11111111.11111111.00000000 256 254

Subnetting techniques:

There are various subnetting techniques, like

  • Fixed-length subnet masking (FLSM)
  • Variable-length subnet masking (VLSM)
  • CIDR (Classless Inter-Domain Routing)

Let's take a brief look at each of them and which IP subnetting technique is the right choice for your organization.

Fixed-Length Subnet Masking (FLSM):

Fixed-Length Subnet Masking (FLSM) method involves dividing the entire network into subnets having equal number of hosts. This is a straightforward approach where all subnets can accommodate an equal number of hosts. While it may seem that management becomes easier with the FLSM (Fixed Length Subnet Mask) method, it is not efficient when the network has varying size requirements. This approach can sometimes lead to IP address wastage.

Let's consider you need to create four subnets for a Class C network using FLSM.

Default subnet mask for class C network - 255.255.255.0

However, we need four subnets. Let's consider the host range to be 192.168.1.0 to 192.168.1.255. So, the subnet mask would be 255.255.255.192.

Here is how the subnets are divided.

  • Subnet 1: 192.168.1.0 to 192.168.1.63
  • Subnet 2: 192.168.1.64 to 192.168.1.127
  • Subnet 3: 192.168.1.128 to 192.168.1.191
  • Subnet 4: 192.168.1.192 to 192.168.1.255

Variable-length subnet masking (VLSM):

Variable-length subnet masking (VLSM) allows you to create subnets with different sizes within the same network, thereby enabling efficient use of IPs. This method ensures the subnets are tailored depending on the network's needs without IP address wastage.

Let's consider the same Class C network with range 192.168.1.0 to 192.168.1.255 as example.

But say, you want four subnets, each with different sizes. Say one accommodating 100 hosts, one for 50, and two subnets for 25 hosts, each.

Here's how the subnets can be divided.

  • Subnet 1: 192.168.1.0/25 (126 usable hosts)
  • Subnet 2: 192.168.1.128/26 (62 usable hosts)
  • Subnet 3: 192.168.1.192/27 (30 usable hosts)
  • Subnet 4: 192.168.1.224/27 (30 usable hosts)

where the number after "/" represents the host part, which is explained briefly in the next paragraph.


CIDR (Classless Inter-Domain Routing):

CIDR (Classless Inter-Domain Routing) method helps allocate IP address for IP routing. This method allows route aggregation, reducing the number of routing entries. In this method, subnets of different sizes can be created without the limitations offered by IP classes. This method again reduces IP wastage.

A CIDR looks like 192.168.1.0/24 where 24 indicates the first 24 bits that represents the network part. Rest of the 8 bits represent the host part.

For example, multiple networks such as 192.168.0.0/24 and 192.168.1.0/24 are combined into a single CIDR block like 192.168.0.0/23, thereby reducing the number of routes in the routing table.

Network 1: 192.168.0.0/24

  • Range: 192.168.0.0 to 192.168.0.255
  • Subnet Mask: 255.255.255.0
  • Number of Hosts: 256 (254 usable)

Network 2: 192.168.1.0/24

  • Range: 192.168.1.0 to 192.168.1.255
  • Subnet Mask: 255.255.255.0
  • Number of Hosts: 256 (254 usable)

Combined Network: 192.168.0.0/23

  • Range: 192.168.0.0 to 192.168.1.255
  • Subnet Mask: 255.255.254.0
  • Number of Hosts: 512 (510 usable)

Before combining: Two separate routes

  • Route 1: 192.168.0.0/24
  • Route 2: 192.168.1.0/24

After combining: One single route

Route: 192.168.0.0/23

Hence, out of all IP subnetting techniques, CIDR is more efficient and scalable.

Best practices of IP subnetting

  • Efficient subnet planning: Strategically design subnets to enhance performance, security, and future growth needs.
  • Documentation: Maintain detailed records of subnet allocations and changes to facilitate troubleshooting and management.
  • Regular optimization of subnets: Periodically assess subnet configurations to optimize network performance and resource utilization.

How OpUtils helps you manage your subnets effectively?

OpUtils is a comprehensive IP address management and switch port mapping solution that helps IT administrators manage their IP address space with ease. The in-built subnet monitoring capability within OpUtils helps you manage the subnets within your network efficiently.

With OpUtils' IP address subnet monitoring tool, you can perform a wide range of actions. Some of them are:

  • Real-time monitoring: Continuously scans and updates the real-time status of subnet utilization and availability.
  • Detailed subnet insights: Offers a thorough summary, including reserved IP counts, usage percentages, DNS status, and more.
  • Hierarchical view: Supports organized visualization of both IPv4 and IPv6 subnets.
  • Historical tracking: Maintains records of IP usage, associated users, devices, and connected ports over time.
  • Customizable dashboard: Utilizes widgets to measure subnet performance, such as listing the top 10 subnets with the most occupied IPs.
  • Comprehensive reports: Produces detailed reports on specific subnets, facilitating audits of the associated IP addresses.

This is just an overview of what OpUtils can do for you. Download our 30 days free trial and try it yourself to see how OpUtils can monitor your subnetted space. You can also schedule a demo, and we will connect you with the right product expert who can clear product-related queries.

Ensure seamless IP management with OpUtils

Try OpUtils for free today
OpUtils

Resources