Why subnet? Segmenting an IP network
In the previous lesson on classful addressing, we saw how organizations were assigned large, fixed blocks of IP addresses, such as a Class B or C network. A shared broadcast domain can then include many devices. It increases the scope of broadcast traffic, limits department separation, and makes different access rules harder to apply.
Subnetting creates smaller broadcast domains. An administrator can assign them to departments, services, or security zones. Broadcast traffic then remains within the relevant subnet, while routing devices can apply access controls between subnets.
is the networking equivalent of this. It is a basic technique that allows a network administrator to divide one large IP network block into smaller, more manageable sub-networks, or subnets.
Benefits of subnetting
- Improved Performance: Segmenting a network reduces 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 security policies to be applied between different parts of the network. For example, a firewall can 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 supports more structured allocation of IP addresses within an organization, although traditional subnetting still has limitations.
The subnet mask and address division
Subnetting is based on the subnet mask. Every IPv4 address has a network part and a host part. An IPv4 subnet mask is a 32-bit number that tells a device which part of the address belongs to the network or subnet and which part belongs to the host.
The rule is simple:
- A
1in the subnet mask corresponds to a bit in the IP address that belongs to the network/subnet part. - A
0in the subnet mask corresponds to a bit in the IP address that belongs to the host part.
Borrowing bits in 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 an administrator borrows from the host portion, the more subnets can be created. 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 tradeoff in subnetting.
Practical Example 1: Subnetting a Class C Network
Consider a common scenario. 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 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 , where is the number of bits to borrow.
- If we borrow 1 bit (), we get subnets. Not enough.
- If we borrow 2 bits (), we get 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 1s: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 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 ().
Step 3: Determine the Number of Hosts per Subnet
We started with 8 host bits. After borrowing 2 for the subnets, we have bits remaining for hosts. We use the formula .
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.
| Subnet | Borrowed Bits (Binary) | Network Address | Usable Host Range | Broadcast Address |
|---|---|---|---|---|
| 1 (Sales) | ...00|000000 | 192.168.10.0 | 192.168.10.1 - 192.168.10.62 | 192.168.10.63 |
| 2 (Engineering) | ...01|000000 | 192.168.10.64 | 192.168.10.65 - 192.168.10.126 | 192.168.10.127 |
| 3 (Admin) | ...10|000000 | 192.168.10.128 | 192.168.10.129 - 192.168.10.190 | 192.168.10.191 |
| 4 (Guest) | ...11|000000 | 192.168.10.192 | 192.168.10.193 - 192.168.10.254 | 192.168.10.255 |
In each subnet, the Network Address is where all host bits are '0'. The Broadcast Addressis 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 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: .
- subnets. Not enough.
- 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 ().
Step 3: Calculate Hosts per Subnet
The original host portion had 16 bits. We borrowed 10, leaving host bits.
Usable hosts = . 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, broadcast 172.16.0.63) - Subnet 2:
172.16.0.64/26(host range 172.16.0.65 - 172.16.0.126, broadcast 172.16.0.127) - Subnet 3:
172.16.0.128/26(host range 172.16.0.129 - 172.16.0.190, broadcast 172.16.0.191) - Subnet 4:
172.16.0.192/26(host range 172.16.0.193 - 172.16.0.254, broadcast 172.16.0.255) - Subnet 5:
172.16.1.0/26. The last octet resets after four subnets, and the third octet increments. - Subnet 1024:
172.16.255.192/26(host range 172.16.255.193 - 172.16.255.254, broadcast 172.16.255.255)
The limitation of fixed-size subnets
We have solved the problem of organizing a large network into smaller, manageable departments. However, this traditional method of subnetting still has one limitation: 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 address waste on a smaller scale. To reduce this waste, network engineers developed more advanced techniques:
- Variable Length Subnet Masking (VLSM)
- Classless Inter-Domain Routing (CIDR)
These techniques allow administrators to create subnets of different sizes suited to the needs of each network segment. They will be covered in the next lesson.