Subnetting

Dividing IP networks into smaller subnetworks for efficient address allocation.

Why Subnet? From a Single Large Room to Organized Departments

In the previous lesson on classful addressing, we saw how organizations were assigned large, fixed blocks of IP addresses (like a Class B or C network). Imagine being given a giant, open-plan office building for your company. While you have a single address for the whole building, having all your employees (from Sales to Engineering to HR) working in one enormous, chaotic room is incredibly inefficient. Communication becomes noisy, security is non-existent, and it's impossible to manage resources effectively.

The logical solution is to put up walls and create smaller, dedicated departments. This improves organization, security (you can lock the door to the server room), and performance (conversations in the Sales department don't interrupt the focused work in Engineering).

is the networking equivalent of this. It's a fundamental technique that allows a network administrator to take a single, large IP network block and divide it into multiple smaller, more manageable sub-networks, or subnets.

Core Benefits of Subnetting

  • Improved Performance: By segmenting a network, you reduce overall network traffic. Traffic intended for devices within a subnet stays within that subnet, rather than being broadcast to every single device on the entire network.
  • Enhanced Security: Subnets allow you to implement security policies between different parts of your network. For example, you can use a firewall to restrict access to the Finance department's subnet from the guest Wi-Fi subnet.
  • Simplified Administration: Managing smaller, logically grouped networks is much easier than managing one massive, flat network.
  • Address Allocation Efficiency: It helps in more structured allocation of IP addresses within an organization, even though, as we'll see, traditional subnetting still has limitations.

The Tool for Division: The Subnet Mask

The magic behind subnetting lies in the subnet mask. We learned that every IP address has a network part and a host part. A subnet mask is a 32-bit number that tells a device which part of an IP address is the network (and now subnet) portion, and which part is the host portion.

The rule is simple:

  • A `1` in the subnet mask corresponds to a bit in the IP address that belongs to the network/subnet part.
  • A `0` in the subnet mask corresponds to a bit in the IP address that belongs to the host part.

Borrowing Bits: The Heart of Subnetting

To create subnets, an administrator effectively "borrows" bits from the original host portion of the address and reassigns them to be part of the network portion. This creates a new, third level in the address hierarchy:

[ Network ID ] [ Subnet ID ] [ Host ID ]

The more bits you borrow from the host portion, the more subnets you can create. However, borrowing bits reduces the number of bits available for hosts, meaning each subnet will be smaller and can accommodate fewer devices. This is the fundamental tradeoff in subnetting.

Practical Example 1: Subnetting a Class C Network

Let's walk through a common scenario. Imagine a small company has been assigned the Class C network 192.168.10.0. The default subnet mask is 255.255.255.0. This gives them one network with 28−2=2542^8 - 2 = 254 usable host addresses.

The Goal: The company needs to create at least 4 separate networks for different departments: Sales, Engineering, Administration, and a guest network.

Step 1: Determine the Number of Bits to Borrow

We use the formula 2S≥number of required subnets2^S \ge \text{number of required subnets}, where SS is the number of bits to borrow.

  • If we borrow 1 bit (S=1S=1), we get 21=22^1 = 2 subnets. Not enough.
  • If we borrow 2 bits (S=2S=2), we get 22=42^2 = 4 subnets. This meets our requirement.

So, we will borrow 2 bits from the host portion.

Step 2: Calculate the New Subnet Mask

The default mask for a Class C network is 255.255.255.0. In binary, this is:
11111111.11111111.11111111.00000000
We borrow 2 bits from the host part (the last octet) and turn them into `1`s:
11111111.11111111.11111111.11000000
Now we convert this back to dotted-decimal notation. The first three octets are still 255. The last octet is 11000000 in binary, which is 128+64=192128 + 64 = 192 in decimal.
The new subnet mask is 255.255.255.192. In CIDR notation, the default `/24` mask becomes `/26` because we added 2 bits to the network part (24+2=2624+2=26).

Step 3: Determine the Number of Hosts per Subnet

We started with 8 host bits. After borrowing 2 for the subnets, we have H=8−2=6H = 8 - 2 = 6 bits remaining for hosts. We use the formula 2H−2=usable hosts2^H - 2 = \text{usable hosts}.
26−2=64−2=622^6 - 2 = 64 - 2 = 62 usable hosts per subnet.

Step 4: List the Subnets

The 2 bits we borrowed can have four possible combinations: `00`, `01`, `10`, and `11`. Each combination defines a unique subnet. We find the network addresses by setting all remaining host bits to 0.

SubnetBorrowed Bits (Binary)Network AddressUsable Host RangeBroadcast Address
1 (Sales)...00|000000192.168.10.0192.168.10.1 - 192.168.10.62192.168.10.63
2 (Engineering)...01|000000192.168.10.64192.168.10.65 - 192.168.10.126192.168.10.127
3 (Admin)...10|000000192.168.10.128192.168.10.129 - 192.168.10.190192.168.10.191
4 (Guest)...11|000000192.168.10.192192.168.10.193 - 192.168.10.254192.168.10.255

In each subnet, the Network Address is where all host bits are '0'. The Broadcast Address is where all host bits are '1', and is used to send messages to all devices on that specific subnet. The addresses in between are assignable to devices.

Practical Example 2: Subnetting a Class B Network

Now let's consider a larger scenario. A university has been assigned the Class B network 172.16.0.0. The default mask is 255.255.0.0 or `/16`. This gives them 216−2=65,5342^{16} - 2 = 65,534 host addresses in one giant network.

The Goal: The university wants to create at least 1,000 subnets for different faculties, labs, and administrative buildings.

Step 1: Determine Bits to Borrow

Formula: 2S≥10002^S \ge 1000.

  • 29=5122^9 = 512 subnets. Not enough.
  • 210=10242^{10} = 1024 subnets. This meets the requirement.
We will borrow 10 bits from the host portion.

Step 2: Calculate the New Subnet Mask

The default host portion is the last two octets (16 bits). We borrow 10 of these bits.
Original Mask (`/16`): 11111111.11111111.00000000.00000000
We borrow the first 8 bits from the third octet and the first 2 bits from the fourth octet:
New Mask: 11111111.11111111.11111111.11000000
This converts to 255.255.255.192. The new prefix length is `/26` (16+10=2616+10=26).

Step 3: Calculate Hosts per Subnet

The original host portion had 16 bits. We borrowed 10, leaving H=16−10=6H = 16 - 10 = 6 host bits.
Usable hosts = 26−2=622^6 - 2 = 62. So we will have 1024 subnets, each with 62 usable addresses.

Step 4: Listing the Subnets

With 1024 subnets, listing them all is impractical. The subnets will increment by a "block size" of 64 in the last octet.

  • Subnet 1: 172.16.0.0 /26 (Host range: 172.16.0.1 - 172.16.0.62)
  • Subnet 2: 172.16.0.64 /26 (Host range: 172.16.0.65 - 172.16.0.126)
  • Subnet 3: 172.16.0.128 /26 (Host range: 172.16.0.129 - 172.16.0.190)
  • ...and so on...
  • Subnet 256: 172.16.255.192 /26 (This would be the last subnet using the third octet `255`).
  • ... continuing all the way to...
  • Subnet 1024: 172.16.255.192 /26 is incorrect, the calculation spans octets. Let's list a few correctly:
    Subnet 1: `172.16.0.0`
    Subnet 2: `172.16.0.64`
    Subnet 3: `172.16.0.128`
    Subnet 4: `172.16.0.192`
    Subnet 5: `172.16.1.0` (The last octet resets, and the third octet increments)...

The Remaining Problem: Fixed-Size Subnets

We have solved the problem of organizing a large network into smaller, manageable departments. However, this traditional method of subnetting has a significant remaining flaw: all the subnets we create must be the same size.

In our university example, we created 1024 subnets, each capable of supporting 62 devices. This works well for a department with 50 computers. But what about the connection between two core routers, which only needs 2 IP addresses (one for each end of the link)? We would still have to assign an entire subnet of 62 addresses, wasting 60 of them. What about a small lab with only 10 computers? We still assign a block of 62, wasting 52.

This inflexibility still leads to significant address waste, just on a smaller scale. To solve this final piece of the efficiency puzzle, network engineers developed more advanced techniques:

  • Variable Length Subnet Masking (VLSM)
  • Classless Inter-Domain Routing (CIDR)

These crucial technologies, which allow administrators to create subnets of different sizes to perfectly match the needs of each network segment, will be the focus of the next lesson.

Subnetting playground

Adjust your IPv4 network and target prefix to see how many subnets you get and what each range looks like.

Original prefix/16
Subnet prefix/24

Quick subnet presets

Routed block
192.168.0.0/16
Subnet size
/24
Subnet bits8
Host bits8
Number of subnets256
Addresses per subnet256
Usable hosts254
Wildcard mask0.0.0.255

Subnet ranges

256
#NetworkFirst hostLast hostBroadcastUsable hosts
1192.168.0.0/24192.168.0.1192.168.0.254192.168.0.255254
2192.168.1.0/24192.168.1.1192.168.1.254192.168.1.255254
3192.168.2.0/24192.168.2.1192.168.2.254192.168.2.255254
4192.168.3.0/24192.168.3.1192.168.3.254192.168.3.255254
5192.168.4.0/24192.168.4.1192.168.4.254192.168.4.255254
………………
256192.168.255.0/24192.168.255.1192.168.255.254192.168.255.255254

Showing first subnets. Large results are truncated for brevity.

    Subnetting | Teleinf Edu