Kahibaro
Discord Login Register

7.6 Subnetting

Understanding Subnetting

Subnetting is the process of taking one IP network and dividing it into smaller logical networks called subnets. In IPv4 it is how you control which part of the address identifies the network and which part identifies the host. In this chapter the focus stays on the practical idea of splitting networks and recognizing subnet boundaries, without repeating the general IPv4 fundamentals or CIDR concepts that belong to other chapters.

Subnetting matters because it lets you organize networks, reduce waste of addresses, control broadcast traffic, and build clear separation between different departments, locations, or device types.

Network and Host Portions

Every IPv4 address is combined with a subnet mask. Together, these define which bits belong to the network part and which bits belong to the host part. The subnet mask has consecutive 1 bits for the network portion followed by 0 bits for the host portion.

For example, with address 192.168.10.25 and mask 255.255.255.0, the first 24 bits are the network part and the last 8 bits are the host part. In CIDR form, this is written as 192.168.10.25/24.

In subnetting, you start from an existing network and adjust how many bits are used for the network side. When you move the boundary to use more bits for the network portion, you create more subnets but you reduce the number of hosts per subnet.

The subnet mask defines the network and host portions:

  • Network bits are 1s in the mask.
  • Host bits are 0s in the mask.

Borrowing Bits

Subnetting a given network means you "borrow" some of the host bits and treat them as additional network bits. This creates extra subnets inside the original network.

Imagine you have a /24 network. A /24 mask has 24 network bits and 8 host bits. If you change it to /26, you now have 26 network bits and 6 host bits. You have borrowed 2 bits from the host portion to use for subnetting.

The relationship between borrowed bits, the number of subnets, and the number of hosts per subnet can be summarized as follows:

ConceptFormula
Number of subnets$2^{\text{borrowed bits}}$
Number of host addresses$2^{\text{host bits}}$
Usable host addresses$2^{\text{host bits}} - 2$

The subtraction of 2 accounts for the network address and the broadcast address, which cannot be assigned to hosts.

If a subnet has $h$ host bits, then:

  • Total host addresses per subnet = $2^h$
  • Usable host addresses per subnet = $2^h - 2$

Finding Network, Broadcast, and Host Range

For any subnet, three values are especially important: the network address, the broadcast address, and the usable host range. You can find them by using the subnet mask and understanding the increment of the subnet.

The subnet increment tells you how far apart subnet network addresses are. It is based on the value of the last non 255 octet in the subnet mask.

Consider these common masks and increments:

MaskCIDRIncrement in that octetExample networks in that octet
255.255.255.0/242560 (only one subnet in that octet)
255.255.255.128/251280, 128
255.255.255.192/26640, 64, 128, 192
255.255.255.224/27320, 32, 64, 96, 128, 160, 192, 224
255.255.255.240/28160, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240

To find the network of a specific IP address:

  1. Identify the subnet mask and the octet where subnetting happens.
  2. Use the increment in that octet.
  3. Find the multiple of the increment that is less than or equal to the IP's value in that octet. That multiple is the starting value of the subnet, so it is the network address in that octet.
  4. The next multiple of the increment minus 1 is the broadcast value in that octet.
  5. All addresses between the network address and broadcast address are in the same subnet. The first usable host is the network address plus 1. The last usable host is the broadcast address minus 1.

For example, take 192.168.10.77 with mask 255.255.255.192 (/26):

The last mask octet is 192, so the increment is 64. The valid subnet starts are 0, 64, 128, 192. The value 77 falls between 64 and 128. So the network address is 192.168.10.64, and the next subnet would start at 192.168.10.128. The broadcast address is therefore 192.168.10.127. The usable hosts run from 192.168.10.65 to 192.168.10.126.

Subnetting a Given Network

Subnetting usually begins with a single block that you are given, for instance 192.168.1.0/24. You then decide how many subnets you need, or how many hosts you must support in each subnet.

If you want more subnets than the original classful boundary provides, you increase the prefix length. Each extra network bit you add doubles the number of subnets and halves the host space in that part of the address.

If you have 192.168.1.0/24 and you change it to /26, you have borrowed 2 bits. From the formulas, you now have $2^2 = 4$ subnets. Each subnet has 6 host bits, which gives $2^6 = 64$ addresses, with 62 usable for hosts.

The four /26 subnets inside 192.168.1.0/24 are:

SubnetNetwork addressBroadcast addressUsable host range
1192.168.1.0192.168.1.63192.168.1.1 to 192.168.1.62
2192.168.1.64192.168.1.127192.168.1.65 to 192.168.1.126
3192.168.1.128192.168.1.191192.168.1.129 to 192.168.1.190
4192.168.1.192192.168.1.255192.168.1.193 to 192.168.1.254

Subnetting is about listing exactly these possible smaller blocks, then assigning them to different parts of your network such as floors, departments, or sites.

From Required Subnets to Mask

Sometimes you know how many subnets you need, and you want to find the correct subnet mask. In that case you convert the requirement into borrowed bits.

To get at least a certain number of subnets $N$, you need $b$ bits such that:

$$2^b \ge N$$

The value $b$ is the number of bits you must borrow. Once you know $b$, you add it to the original prefix length to get the new prefix length. From that new prefix, you can derive the subnet mask.

For example, suppose you start with 10.0.0.0/24 and require 5 subnets. You find the smallest $b$ with $2^b \ge 5$:

For $b = 2$, $2^2 = 4$ (too small).
For $b = 3$, $2^3 = 8$ (enough).

So you must borrow 3 bits. The new prefix is /27. The new mask is 255.255.255.224. This provides 8 subnets, which covers your need for 5 subnets.

To find required borrowed bits for at least $N$ subnets, choose the smallest $b$ such that:
$$2^b \ge N$$
New prefix length = original prefix length + $b$.

From Required Hosts to Mask

In other cases, you must support a certain number of hosts in each subnet, and you want to know the correct subnet size. In this situation you choose how many host bits to leave unborrowed.

To support at least $H$ usable hosts per subnet, you find $h$ such that:

$$2^h - 2 \ge H$$

The value $h$ is the number of host bits that must remain. Once you know $h$, you can find the prefix length by subtracting $h$ from 32, and then convert that prefix to a mask.

For example, if you need at least 50 hosts per subnet, you solve for $h$:

For $h = 5$, $2^5 - 2 = 30$ (too small).
For $h = 6$, $2^6 - 2 = 62$ (enough).

So you need 6 host bits. That means the prefix length is $32 - 6 = 26$, which gives a mask of 255.255.255.192.

To support at least $H$ usable hosts per subnet, choose the smallest $h$ such that:
$$2^h - 2 \ge H$$
Prefix length = $32 - h$.

Subnetting Across Octet Boundaries

Many simple examples keep subnetting inside a single octet, but in real networks you often use masks where the boundary falls between octets, for example /19 or /21.

When subnetting across octets, you still follow the same principles. The key is to identify which octet contains the subnet bits. That octet will not be 0 or 255 in the mask, but a value such as 128, 192, 224, 240, 248, 252, or 254.

For example, consider 172.16.0.0/16 subnetted to /20. You have added 4 bits to the network portion. In dotted form, /20 corresponds to 255.255.240.0.

The third octet has 240. This is where the subnet increments occur. The increment in that octet is 16. The possible subnet starts in the third octet are 0, 16, 32, 48, and so on.

So the first few /20 subnets inside 172.16.0.0/16 are:

SubnetNetwork addressBroadcast address
1172.16.0.0172.16.15.255
2172.16.16.0172.16.31.255
3172.16.32.0172.16.47.255
4172.16.48.0172.16.63.255

The host bits span the third and fourth octets in each case, but the idea is still the same. You treat the varying octet and the following octet as the host space for each subnet.

Avoiding Overlap and Wasted Space

When you plan subnets, you must ensure that they never overlap. Two different subnets cannot share any IP address. If they do, routing and host configuration will behave unpredictably.

Also, if you choose subnets that are far larger than the number of hosts that will actually exist, you waste addresses and might limit how many separate subnets you can create from the same pool. On the other hand, if you choose subnets that are too small, you risk running out of host addresses in that subnet.

For structured networks, engineers often arrange subnets so that related locations share common high order bits. For example, all subnets for a particular building might fall within 10.1.0.0/20, which itself is composed of smaller subnets. This kind of structure is useful later when you perform route summarization.

Practice-Oriented Subnetting Strategy

For practical subnetting, a simple mental checklist is helpful:

First, identify what you were given: address block and current prefix length.
Second, clarify what you need: number of subnets or hosts per subnet.
Third, calculate either borrowed bits or host bits with the formulas above.
Fourth, derive the new prefix and mask.
Fifth, calculate subnet increments and list specific network, broadcast, and host ranges as needed.

Subnetting becomes much easier with repetition, so working through many small examples is an effective way to gain speed and confidence.

Views: 45

Comments

Please login to add a comment.

Don't have an account? Register now!