Unit

How to Create Subnets

Learn how to create IPv4 subnets by choosing CIDR prefixes, borrowing host bits, calculating ranges, assigning gateways, and checking subnet validity.

Subnetting divides one larger IPv4 network into smaller logical networks. This lesson shows how to choose a subnet mask, calculate subnet boundaries, identify usable host addresses, and assign addresses safely.

You should understand IPv4 dotted-decimal notation, binary numbers, powers of two, routers, and default gateways. For background, see Computer Network Explained and IP Routing Explained.

Why Create Subnets?

A subnet is a smaller logical network made from part of a larger IP network. A subnet mask determines which bits identify the network and which bits identify hosts.

Subnetting is useful because it provides:

  • Address allocation: You can assign separate address ranges to offices, departments, buildings, or applications.
  • Broadcast containment: Broadcast traffic stays within its subnet instead of reaching every device in the larger network.
  • Network organization: Devices with similar roles can share a clearly defined address range.
  • Routing boundaries: Routers can forward traffic between subnets using routing tables.
  • Basic isolation: Separate subnets provide a foundation for access-control rules, although subnetting alone is not a complete security control.

A router interface commonly serves as the default gateway for a subnet. Hosts send traffic for other subnets to that gateway.

IPv4 Address and Subnet Mask Fundamentals

An IPv4 address contains 32 bits, normally written as four decimal octets. For example, 192.168.10.65 represents four 8-bit values.

A subnet mask divides those 32 bits into a network portion and a host portion. The network portion identifies the subnet. The host portion identifies an individual interface within that subnet.

CIDR prefix length writes the number of network bits after a slash. In 192.168.10.0/24, the first 24 bits are network bits and the remaining 8 bits are host bits.

The same /24 prefix can be written as the dotted-decimal mask 255.255.255.0. Mask bits are 1 for network positions and 0 for host positions.

Common CIDR Prefixes and IPv4 Capacities

CIDR prefix | Dotted-decimal mask | Total addresses | Usable host addresses | Typical use

/24 | 255.255.255.0 | 256 | 254 | Small LAN

/25 | 255.255.255.128 | 128 | 126 | Half of a /24

/26 | 255.255.255.192 | 64 | 62 | Small department or LAN

/27 | 255.255.255.224 | 32 | 30 | Small segment

/28 | 255.255.255.240 | 16 | 14 | Very small segment

/29 | 255.255.255.248 | 8 | 6 | Small infrastructure segment

/30 | 255.255.255.252 | 4 | 2 | Point-to-point IPv4 link

Older classful terminology associated Class A with /8, Class B with /16, and Class C with /24 default masks. Modern planning uses CIDR rather than relying on those classes. Private IPv4 ranges defined by RFC 1918 are commonly used inside organizations; see Private IP Addresses.

Borrowing Host Bits

Subnetting creates additional network identifiers by borrowing bits from the original host portion. The borrowed bits become subnet ID bits. The bits left over remain host ID bits.

For a parent network with n borrowed bits:

  • Number of equal-sized subnets = 2^n
  • Number of addresses in each subnet = 2^h, where h is the number of remaining host bits
  • Usable IPv4 host addresses per subnet = 2^h - 2

The subtraction reserves one address for the subnet's network address and one for its broadcast address. This is the conventional rule for ordinary IPv4 subnets. Special point-to-point designs and some equipment may support exceptions such as /31 links, but do not use that exception for ordinary LAN host planning.

Example: Splitting a /24 into /26 borrows two bits. Therefore, there are 2^2 = 4 subnets. A /26 leaves six host bits, so each subnet has 2^6 = 64 total addresses and 64 - 2 = 62 usable host addresses.

Selecting an Appropriate Prefix Length

There are two common requirements: the number of subnets and the number of hosts needed in each subnet.

When the subnet count is the requirement

Choose the smallest number of borrowed bits n for which 2^n is at least the required number of subnets. For example, four subnets require two borrowed bits because 2^2 = 4.

When the host count is the requirement

Choose enough remaining host bits h for which 2^h - 2 is at least the required number of usable hosts. For at least 50 usable hosts, six host bits are needed: 2^6 - 2 = 62. A /26 has six host bits, while a /27 has only 30 usable hosts, so /26 is the correct choice.

When both requirements apply

Test a candidate prefix against both formulas. A prefix is valid only when it provides enough subnets and enough usable hosts per subnet. A longer prefix creates more subnets but fewer hosts in each subnet. A shorter prefix provides more hosts per subnet but fewer equal-sized subnets.

Subnet Calculation Worksheet

Original network | Required subnets | Required hosts per subnet | Borrowed bits | New prefix | New mask | Block size

192.168.10.0/24 | 4 | 50 or more | 2 | /26 | 255.255.255.192 | 64

10.20.0.0/24 | 2 or more | 50 | 2 | /26 | 255.255.255.192 | 64

Calculating Subnet Boundaries

The block size, also called the increment, tells you how far apart consecutive subnet network addresses are in the relevant octet.

  1. Write the new prefix as a dotted-decimal mask.
  2. Find the first mask octet that is neither 255 nor 0.
  3. Calculate the block size as 256 - mask-octet value.
  4. List network addresses by adding that block size in the relevant octet.
  5. For each subnet, the broadcast address is one less than the next subnet's network address.
  6. The first usable host is the network address plus one.
  7. The last usable host is the broadcast address minus one.

For /26, the mask is 255.255.255.192. The relevant octet is the fourth octet, and the increment is 256 - 192 = 64. The subnet network addresses within 192.168.10.0/24 are therefore .0, .64, .128, and .192.

Worked Example: Four Equal /26 Subnets

Requirement: divide 192.168.10.0/24 into four equal-sized subnets.

  1. Four subnets require two borrowed bits: 2^2 = 4.
  2. The new prefix is /24 + 2 = /26.
  3. The mask is 255.255.255.192.
  4. There are 64 total addresses and 62 usable host addresses per subnet.
  5. The increment is 64.

Subnet Allocation Table

Subnet number | Network address | CIDR prefix | First usable host | Last usable host | Broadcast address | Gateway assignment

1 | 192.168.10.0 | /26 | 192.168.10.1 | 192.168.10.62 | 192.168.10.63 | 192.168.10.1

2 | 192.168.10.64 | /26 | 192.168.10.65 | 192.168.10.126 | 192.168.10.127 | 192.168.10.65

3 | 192.168.10.128 | /26 | 192.168.10.129 | 192.168.10.190 | 192.168.10.191 | 192.168.10.129

4 | 192.168.10.192 | /26 | 192.168.10.193 | 192.168.10.254 | 192.168.10.255 | 192.168.10.193

The gateway choice is a convention, not a mathematical requirement. You could reserve the first usable address, the last usable address, or another documented address. Every host's gateway must be inside that host's subnet.

Identifying the Subnet for a Given Host

Given 192.168.10.130/26, compare the last octet with the /26 boundaries: 0, 64, 128, and 192. The value 130 falls between 128 and 191.

  • Network address: 192.168.10.128
  • Broadcast address: 192.168.10.191
  • Usable range: 192.168.10.129 through 192.168.10.190
  • Host status: 192.168.10.130 is valid and belongs to the third /26 subnet

To verify any address, calculate its network address using the address and mask. If the result matches the intended subnet network address, the address belongs to that subnet. It must also be different from the network and broadcast addresses.

Binary Subnetting Method

Binary is useful for understanding and checking subnet calculations. For a /26 mask, the last octet looks like this:

Address:  192.168.10.00xxxxxx through 192.168.10.11xxxxxx
Mask:     255.255.255.11000000
                         ^^ borrowed subnet bits
                           ^^^^^^ host bits

The two borrowed bits identify four subnet IDs: 00, 01, 10, and 11. The six host bits vary within each subnet.

Binary-to-Decimal Subnet Boundary Reference

Borrowed-bit pattern | Binary boundary value | Decimal subnet increment | Resulting subnet start

00 | 00000000 | 0 | 192.168.10.0

01 | 01000000 | 64 | 192.168.10.64

10 | 10000000 | 128 | 192.168.10.128

11 | 11000000 | 192 | 192.168.10.192

Decimal block-size calculations are usually faster. Use the binary method as a verification technique and when a prefix crosses an octet boundary.

Subnet Range Diagram

192.168.10.0/24 divided into /26 blocks

.0       .1 ---------------- .62      .63
| network |     usable hosts             | broadcast |

.64      .65 --------------- .126     .127
| network |     usable hosts             | broadcast |

.128     .129 -------------- .190     .191
| network |     usable hosts             | broadcast |

.192     .193 -------------- .254     .255
| network |     usable hosts             | broadcast |

Worked Subnetting Workflow

  1. Start with the parent network: Record its network address and original prefix.
  2. Write the requirements: Include the number of subnets, required hosts, infrastructure addresses, and growth capacity.
  3. Choose a prefix: Check both subnet capacity and usable host capacity.
  4. Convert the prefix to a mask: Confirm the dotted-decimal representation.
  5. Calculate the block size: Use the first partial mask octet.
  6. List all subnet network addresses: Continue in the correct increment.
  7. Calculate each range: Find network, first host, last host, and broadcast addresses.
  8. Assign gateways and reservations: Document router interfaces, servers, printers, DHCP scopes, and exclusions.
  9. Check for overlap: Ensure every subnet starts on a valid boundary and no address range is reused.

A small routed design might contain 192.168.10.0/26 for Administration, 192.168.10.64/26 for Engineering, 192.168.10.128/26 for Sales, and 192.168.10.192/26 for Guest devices. A router has one interface or logical interface in each subnet, and hosts use the corresponding gateway.

Fixed-Length Subnetting and VLSM

Fixed-length subnetting gives every subnet the same prefix and capacity. It is simple to calculate and document, but it can waste addresses when departments have very different sizes.

Variable Length Subnet Masking (VLSM) assigns different prefix lengths to different subnets. For example, a large department might receive /26, a smaller department /27, and a point-to-point link /30. VLSM uses addresses more efficiently, but every range must be aligned correctly and routing plans must account for the different prefixes.

Address Validity and Restrictions

  • Do not assign a conventional subnet's network address to an ordinary host.
  • Do not assign its broadcast address to an ordinary host.
  • Check that a proposed host address is within the valid host range.
  • Do not overlap subnet ranges.
  • All devices intended to communicate directly on the same local subnet must use compatible masks. Different masks can cause devices to disagree about whether a destination is local or remote.
  • Keep the gateway inside the subnet and reserve its address consistently.

Assigning and Checking Addresses

For the second /26 subnet in the example, an illustrative configuration is:

IP address:     192.168.10.65
Prefix length:  /26
Subnet mask:    255.255.255.192
Default gateway: 192.168.10.66

Both 192.168.10.65 and 192.168.10.66 are valid hosts in the range 192.168.10.65–192.168.10.126. The gateway could instead be .65, but the host and gateway must not use the same address.

On Windows, inspect addressing with:

ipconfig
ipconfig /all

On Linux, inspect addresses and routes with:

ip addr show
ip route show

Test connectivity after assigning addresses:

ping <destination-ip>
traceroute <destination-ip>
tracert <destination-ip>

Troubleshooting Subnet Problems

Hosts intended to communicate locally cannot reach each other

  • Compare the address and prefix on every host.
  • Calculate each host's network address.
  • Confirm both hosts are in the same valid usable range.
  • Check that neither host received a network or broadcast address.

A host cannot reach addresses outside its subnet

  • Verify that a default gateway exists and belongs to the host's subnet.
  • Check the router interface address and mask.
  • Inspect local routes and router routes.
  • Test the gateway before testing a remote destination.

Two subnets overlap

  • Recalculate the block size.
  • Confirm every subnet starts at a boundary aligned with its prefix.
  • List every network and broadcast address in an allocation table.
  • Check that a range has not been allocated twice.

The planned subnet lacks enough client addresses

  • Recalculate usable hosts from the remaining host bits.
  • Do not count the network and broadcast addresses as client addresses.
  • Include gateways, servers, printers, exclusions, and growth in the requirement.
  • Select a shorter prefix if the parent network has enough available space.

Subnetting Practice

Exercise 1: Count subnets

You borrow three bits from a /24 network. How many equal-sized subnets result, and what prefix is created?

Check: 2^3 = 8 subnets and /24 + 3 = /27.

Exercise 2: Count usable hosts

How many usable hosts are available in a /27 subnet?

Check: A /27 leaves five host bits, so 2^5 - 2 = 30 usable hosts.

Exercise 3: Meet a host requirement

Choose a prefix for 10.20.0.0/24 that supports at least 50 usable hosts per subnet. Compare /26 and /27.

Check: /26 provides 62 usable hosts; /27 provides 30. Select /26.

Exercise 4: Find a subnet range

For 192.168.10.130/26, identify the network, broadcast, first usable, and last usable addresses.

Check: Network 192.168.10.128, broadcast 192.168.10.191, first usable 192.168.10.129, and last usable 192.168.10.190.

Exercise 5: Check overlap

A plan lists 192.168.10.0/26 and 192.168.10.32/27. Do they overlap?

Check: Yes. The /26 range is .0–.63, while the /27 range is .32–.63. The second subnet is inside the first and is not a separate non-overlapping allocation.

Exercise 6: Create an allocation table

Divide 172.16.5.0/24 into four equal subnets. Record each network, usable range, broadcast, and gateway.

Check: Use /26, mask 255.255.255.192, and increment 64. The network starts are .0, .64, .128, and .192. Assign one distinct usable gateway address in each range.

Key Points

  • A subnet mask separates network bits from host bits.
  • Borrowed host bits create subnet IDs.
  • 2^n gives equal-sized subnet count, and 2^h - 2 gives conventional usable IPv4 hosts per subnet.
  • The block size is usually 256 - the relevant mask octet.
  • Each subnet has a network address, a usable host interval, and a broadcast address.
  • Document gateways and reservations, and always check masks, boundaries, and overlap.