IP Routing and Subnetting with CIDR on Linux
I subdivided a /24 into role-based CIDR subnets and configured a Linux host as a router to forward traffic between them. Correct subnet sizing and route tables produced verified end-to-end reachability with no overlap or black-hole routes.
Objective & Context
Subnetting controls broadcast domains and enforces segmentation; routing connects those segments. This lab plans address space with VLSM and turns a multi-homed Linux box into a forwarding router, the foundation for the VLAN and zero-trust segmentation labs.
Environment & Prerequisites
- A Linux router VM with two interfaces; two client VMs.
ipcalcfor subnet math; iproute2 for routes.- A /24 to subdivide (for example 192.168.10.0/24).
flowchart LR
A[Subnet A
192.168.10.0/26] --> R[Linux Router
ip_forward=1] R --> B[Subnet B
192.168.10.64/26]
192.168.10.0/26] --> R[Linux Router
ip_forward=1] R --> B[Subnet B
192.168.10.64/26]
Step-by-Step Execution
1. Plan subnets with ipcalc
ipcalc 192.168.10.0/24 --split 60 602. Enable IP forwarding [PRIVILEGED]
sysctl -w net.ipv4.ip_forward=1 && echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf3. Add and inspect routes
ip route add 192.168.10.64/26 via 192.168.10.62 && ip route show192.168.10.0/26 dev eth0 proto kernel scope link
192.168.10.64/26 via 192.168.10.62 dev eth1
Validation & Testing
From a client in subnet A, ping a client in subnet B and trace the path through the router. Pass criteria: successful cross-subnet ping, the router appears as the first hop, and no overlapping routes exist.
traceroute 192.168.10.70Advanced: Troubleshooting
- No cross-subnet traffic: confirm
ip_forward=1and that clients use the router as gateway. - Overlapping subnets: recompute with ipcalc; overlaps cause unpredictable routing.
- Asymmetric routing: ensure return routes exist on both segments.
Key Results
- Segmented one /24 into 2 role-based /26 subnets with zero overlap.
- Achieved verified bidirectional reachability across segments.
- Reduced each broadcast domain by roughly 75% versus a flat /24.
- Documented a reusable VLSM plan for future segments.