A computer network can have hundreds or thousands of connected devices, but does every device need to share the same network? Not necessarily. A network administrator might separate employee computers, servers, printers, and guest devices into smaller groups to make the network easier to manage. The technique behind this approach is called subnetting.

For networking beginners, subnetting often feels like a puzzle involving binary numbers, subnet masks, and unfamiliar calculations. The good news is that you do not need to memorize every possible IP address range. Once you understand how CIDR notation works and how to calculate network boundaries, the process becomes much more manageable.

This guide explains subnetting from the ground up, with practical examples, binary calculations, subnetting formulas, and a variable-length subnetting exercise. By the end, you should be able to calculate common IPv4 subnet ranges and understand why network administrators use different subnet sizes.

What Is Subnetting?

Subnetting is the process of dividing an IP network into smaller logical networks called subnets. Each subnet has its own network prefix and address range.

Imagine a college campus with separate computer labs, administrative offices, and guest Wi-Fi. Keeping all devices in one large network may make administration more complicated. Dividing the network into smaller subnets allows administrators to organize devices according to their purpose and apply appropriate routing and access-control policies.

Subnetting can help organizations:

  • Use available IP address space more efficiently.
  • Organize devices into manageable network segments.
  • Limit the scope of IPv4 broadcast traffic.
  • Simplify network troubleshooting.
  • Support network segmentation when combined with suitable routing and security controls.

Subnetting does not automatically secure a network. Administrators must also configure firewalls, routing, and access permissions correctly.

Understanding IP Addressing

An Internet Protocol (IP) address identifies a network interface so that data can be delivered to the appropriate destination. IPv4 addresses contain 32 bits, conventionally written as four decimal numbers separated by periods.

For example:

192.168.1.70

Each decimal number represents eight bits, known as an octet. Every octet can range from 0 to 255.

An IPv4 address is interpreted using a network prefix:

  • Network portion: Identifies the IP network.
  • Host portion: Identifies an interface within that network.

The prefix length determines how many bits belong to the network portion. The remaining bits are used for host addressing.

Consider 192.168.1.70/24. The /24 prefix means that the first 24 bits identify the network. The corresponding network address is 192.168.1.0, and the host address is within that network’s range.

The important point is that the network boundary is determined by the prefix, not simply by counting the dots in an IP address.

What Is a Subnet Mask?

A subnet mask identifies the network bits and host bits in an IPv4 address. In binary, the network portion consists of 1s and the host portion consists of 0s.

A common subnet mask is:

255.255.255.0

Its binary representation is:

11111111.11111111.11111111.00000000

There are 24 network bits and eight host bits. Therefore, this mask corresponds to the /24 prefix.

Another example is:

255.255.255.192

Its binary representation is:

11111111.11111111.11111111.11000000

This mask contains 26 network bits and six host bits, so it corresponds to /26.

As the prefix gets longer, fewer bits remain for host addresses. A /26 subnet is therefore smaller than a /24 subnet.

What Is CIDR Notation?

Classless Inter-Domain Routing (CIDR) represents an IP network using an address followed by a slash and a prefix length.

For example:

192.168.1.0/26

The /26 indicates that the first 26 bits identify the network. CIDR supports flexible network sizes rather than requiring networks to follow the older fixed Class A, Class B, and Class C allocation model. The approach is documented in RFC 4632, Classless Inter-domain Routing.

Here are common IPv4 prefixes worth learning:

CIDR prefixSubnet maskTotal addressesConventional usable hosts
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242

For conventional IPv4 subnets, the usable-host calculation excludes the network and broadcast addresses. Special cases, such as /31 prefixes on point-to-point links, follow different rules; see RFC 3021.

Notice the pattern: every time the prefix length increases by one, the total number of addresses is halved. A /24 contains 256 addresses, a /25 contains 128, and a /26 contains 64.

That pattern is useful when estimating subnet sizes without recalculating every bit.

How to Calculate Subnets Step by Step

Instead of memorizing a long list of answers, use a consistent method. The following example starts with the network 192.168.1.0/26.

Step 1: Find the number of host bits

IPv4 addresses contain 32 bits. Subtract the prefix length from 32:

Host bits = 32 − prefix length

For /26:

32 − 26 = 6 host bits

Step 2: Calculate the total number of addresses

Raise 2 to the power of the number of host bits:

Total addresses = 2^(host bits)

For six host bits:

2⁶ = 64 addresses

This means each /26 subnet contains 64 addresses.

Step 3: Calculate conventional usable hosts

For an ordinary IPv4 subnet, subtract the network and broadcast addresses:

Usable hosts = 2^(host bits) − 2

For /26:

64 − 2 = 62 usable hosts

This calculation is appropriate for conventional subnets such as /24 through /30, but not every specialized IPv4 prefix follows this rule.

Step 4: Find the subnet mask and block size

A /26 prefix corresponds to the subnet mask:

255.255.255.192

To find the block size, subtract the relevant mask octet from 256:

Block size = 256 − mask value

In this case:

256 − 192 = 64

The subnet boundaries increase in steps of 64 in the fourth octet.

The four /26 networks within 192.168.1.0/24 are:

  • 192.168.1.0/26
  • 192.168.1.64/26
  • 192.168.1.128/26
  • 192.168.1.192/26

Each network contains 64 addresses.

Binary AND: Find the Network Address

The block-size method works well for many common examples. Binary AND explains how a device determines the network address from an IP address and its subnet mask.

Suppose you are given:

  • IP address: 192.168.1.70
  • CIDR prefix: /26
  • Subnet mask: 255.255.255.192

The first three octets are already aligned with the /26 mask. Focus on the final octet.

The decimal value 70 is:

01000110

The final octet of the subnet mask, 192, is:

11000000

Apply the AND operation bit by bit. A result is 1 only when both corresponding bits are 1.

IP address:   01000110   (70)

Subnet mask:  11000000   (192)

              ——–

AND result:   01000000   (64)

The result is 64. Therefore, the network address is:

192.168.1.64/26

This subnet has the following boundaries:

  • Network address: 192.168.1.64
  • First usable host: 192.168.1.65
  • Last usable host: 192.168.1.126
  • Broadcast address: 192.168.1.127

The next subnet starts at 192.168.1.128.

This example is useful because the given IP address is not the network address. It demonstrates how to identify the correct subnet for an individual host.

A Practical Example: Divide One Network into Four Subnets

Imagine a company has the network 192.168.10.0/24 and wants to create four equally sized subnets for Finance, Marketing, Human Resources, and IT.

The original /24 network contains eight host bits. To create four subnets, borrow two bits because:

2² = 4 subnets

The new prefix is:

/24 + 2 = /26

Each subnet has six host bits, 64 total addresses, and 62 conventionally usable host addresses.

DepartmentNetwork addressUsable host rangeBroadcast address
Finance192.168.10.0/26192.168.10.1–192.168.10.62192.168.10.63
Marketing192.168.10.64/26192.168.10.65–192.168.10.126192.168.10.127
Human Resources192.168.10.128/26192.168.10.129–192.168.10.190192.168.10.191
IT192.168.10.192/26192.168.10.193–192.168.10.254192.168.10.255

Each department receives a separate address range. A network administrator can then configure routing and access policies to control how the departments communicate.

However, equal-sized subnets are not always the best design. If one department has 50 devices and another has only 10, assigning the same number of addresses to both may waste address space. That is where Variable Length Subnet Masking becomes useful.

What Is VLSM? Subnetting with Different Network Sizes

Variable Length Subnet Masking (VLSM) allows a network to be divided into subnets of different sizes. Each subnet receives a prefix that suits its host requirements.

Consider a company using 192.168.20.0/24 with three requirements:

  • Department A needs 50 usable host addresses.
  • Department B needs 25 usable host addresses.
  • Department C needs 10 usable host addresses.

Start with the largest requirement so that the larger address block is allocated first.

Department A: 50 hosts

A /26 provides 62 conventional usable host addresses, so it is large enough. Assign 192.168.20.0/26, which occupies .0 through .63.

Department B: 25 hosts

A /27 provides 30 conventional usable host addresses. The next available aligned block begins at .64, so assign 192.168.20.64/27, occupying .64 through .95.

Department C: 10 hosts

A /28 provides 14 conventional usable host addresses. The next available aligned block begins at .96, so assign 192.168.20.96/28, occupying .96 through .111.

The result is:

DepartmentRequired hostsAssigned subnetUsable host range
A50192.168.20.0/26192.168.20.1–62
B25192.168.20.64/27192.168.20.65–94
C10192.168.20.96/28192.168.20.97–110

The three allocations fit inside the original /24 network without overlapping. The remaining addresses can be reserved for future requirements or additional subnets.

This is the practical advantage of VLSM: the administrator can match address-block sizes to different needs instead of giving every group an identical allocation.

Network Address vs. Broadcast Address vs. Host Address

These three address types are easy to confuse when learning subnetting.

Network address: Identifies the subnet itself. In a conventional IPv4 subnet, all host bits are 0.

Broadcast address: Represents the broadcast destination for that subnet. In a conventional IPv4 subnet, all host bits are 1.

Host address: An address within the usable range that can be assigned to an interface.

For example, in 192.168.1.64/26:

  • 192.168.1.64 is the network address.
  • 192.168.1.65 is the first conventional usable host address.
  • 192.168.1.126 is the last conventional usable host address.
  • 192.168.1.127 is the broadcast address.

A common error is to see .70 and assume the network must start at .70. The subnet boundaries are determined by the prefix. Because /26 uses a block size of 64, .70 belongs to the network beginning at .64.

Common Subnetting Mistakes to Avoid

Confusing total addresses with usable hosts. A /26 contains 64 total addresses, but a conventional subnet has 62 usable host addresses. Always identify which quantity the question asks for.

Treating the CIDR prefix as a device count. /26 describes 26 network bits, not 26 devices or 26 subnets.

Assuming every subnet starts at any chosen address. A subnet must begin on a valid boundary for its prefix. For example, /26 boundaries in the last octet occur at 0, 64, 128, and 192.

Using equal-sized subnets for every requirement. Equal-sized subnetting is straightforward, but VLSM can be more efficient when departments need different numbers of addresses.

Treating subnetting as a complete security solution. Separate subnets help organize network traffic, but access control requires properly configured routing, firewalls, and other security measures.

Why Subnetting Matters in Real-World Networking

Subnetting is used in office networks, educational institutions, data centers, and cloud environments.

In an office, separate subnets may be created for employee computers, printers, servers, and guest wireless devices. Routing and security rules can then determine which groups are allowed to communicate.

In cloud computing, CIDR blocks define address ranges for virtual networks and their subnets. Poor planning can create overlapping ranges, complicate connectivity, or limit future expansion. Understanding CIDR therefore helps cloud administrators plan address space before deploying network resources.

Subnetting also supports troubleshooting. When a device cannot communicate with another device, checking IP addresses, subnet masks, and network boundaries can help identify a misconfiguration. It is only one part of troubleshooting, however; routing, DNS, firewall policies, and physical connectivity may also need to be checked.

For networking students, these concepts provide a foundation for studying routing, network design, and IP address management.

Subnetting Practice: Test Your Understanding

Try solving these questions before checking the answers.

Question 1: How many total addresses and conventional usable host addresses does a /27 subnet contain?

Question 2: A device has the IP address 192.168.5.130/26. What is its network address and broadcast address?

Question 3: A team needs 20 usable IPv4 host addresses. Which is the smallest conventional subnet among /28, /27, and /26 that meets the requirement?

Answers and explanations

Answer 1: A /27 leaves five host bits because 32 − 27 = 5. The total is 2⁵ = 32 addresses, with 32 − 2 = 30 conventional usable hosts.

Answer 2: A /26 has a block size of 64 in the fourth octet. The boundaries are 0, 64, 128, and 192. Since 130 falls between 128 and 191, the network address is 192.168.5.128 and the broadcast address is 192.168.5.191.

Answer 3: Choose /27. It provides 30 conventional usable host addresses. A /28 provides only 14, while /26 provides 62 and allocates a larger block than required.

If you can solve these questions and explain why each answer is correct, you are beginning to understand the logic behind subnetting rather than simply memorizing a table.

Subnetting Quick-Reference Cheat Sheet

TaskFormula or rule
Calculate host bits32 − prefix length
Calculate total addresses2^(host bits)
Calculate conventional usable hostsTotal addresses − 2
Find block size256 − relevant mask octet
Find network addressIP address AND subnet mask
Find broadcast addressSet all host bits to 1
Find equal-sized subnetsBorrow bits; 2^(bits borrowed) gives the number of subnets
Choose a subnet sizeSelect a prefix with enough usable addresses for the required hosts

These formulas cover many introductory IPv4 subnetting exercises. Remember that specialized cases, including /31 point-to-point links, require different handling.

Conclusion

Subnetting is easier to understand when each calculation has a clear purpose. The CIDR prefix identifies the network boundary, the host-bit count determines the size of the address block, and the subnet mask helps identify the network address.

A /24 divided into four /26 subnets demonstrates equal-sized subnetting. The VLSM example shows how different departments can receive appropriately sized address ranges. Binary AND explains how to identify the network for an individual IP address, while the practice questions help check whether the process makes sense.

If you are preparing for a networking certification or building practical IT skills, work through different prefixes and verify the network, host, and broadcast addresses for each example. After mastering the calculations, practise configuring IP addresses and subnet masks in a lab environment.

The goal is not simply to calculate subnet ranges quickly. It is to understand how address planning supports a network that is organized, efficient, and easier to maintain.