Inter-VLAN Routing
Time: 30 min
Needs: one Ethernet switch, one OL9 PC, 4 VPCS
GNS3 project: w04-a4-intervlan
Info
Times listed are approximate and provided as timing guidelines only. Take as much time as you need to complete the activity.
Question
How do you enable hosts belonging to separate VLANs to communicate while maintaining broadcast isolation
Build it
Drag an Ethernet Switch on to GNS3 canvas, name it SW1. Right-click it → Configure,
and configure the ports:
| Port | Type | VLAN |
|---|---|---|
| 0 and 1 | access | 10 |
| 2 and 3 | access | 20 |
Cable PC1 and PC2 to the VLAN 10 ports; assign them 192.168.10.11/24
and 192.168.10.12/24 respectively.
Cable PC3 and PC4 to the VLAN 20 ports; assign them 192.168.10.13/24
and 192.168.10.14/24 respectively.
Confirm PC1 can reach PC2 but not the other two.
Part 1 — Change the addressing
On PC1:
ip 192.168.10.11/24 192.168.10.1
save
On PC2:
ip 192.168.10.12/24 192.168.10.1
save
On PC3:
ip 192.168.20.13/24 192.168.20.1
save
On PC4:
ip 192.168.20.14/24 192.168.20.1
save
What just happened
- Routing works at Layer 3. A router forwards between networks. If the hosts are in the same subnet, they will never consult a gateway at all.
- Thus, VLAN 10 and VLAN 20 now map to two separate subnets.
- Note the direction of the dependency: the layer-2 decision (which VLAN) forces the layer-3 decision (which subnet), and not the other way round.
Part 2 — Configure routing
Add an OL9 PC (we are using a PC node because we require only one physical interface)
named R1 and cable it to SW1:Ethernet4. That port has to carry
both VLANs, so set it configure it accordingly:
| Port | Type | VLAN |
|---|---|---|
| 4 | dot1q | 1 |
Log on to R1 as root, then:
nmcli con mod 'System eth0' con-name eth0 \
ipv4.method disabled ipv6.method disabled
nmcli con up eth0
nmcli con add type vlan ifname eth0.10 con-name eth0.10 dev eth0 id 10 \
ipv4.method manual ipv4.addresses 192.168.10.1/24
nmcli con add type vlan ifname eth0.20 con-name eth0.20 dev eth0 id 20 \
ipv4.method manual ipv4.addresses 192.168.20.1/24
nmcli con up eth0.10
nmcli con up eth0.20
echo 'net.ipv4.ip_forward=1' | tee -a /etc/sysctl.d/99-ipv4-routing.conf
ip addr show
ip route show
Start three captures simultaneously on PC1, R1 and PC3 cables.
From PC1: ping 192.168.20.13.
Fill in the following table:
| Capture | Source MAC | Destination MAC | VLAN id in tag | Source IP | Destination IP |
|---|---|---|---|---|---|
PC1 cable -> |
|||||
PC1 cable <- |
|||||
R1 cable -> |
|||||
R1 cable <- |
|||||
PC3 cable -> |
|||||
PC3 cable <- |
What just happened
R1was able to forward the packets across both VLANs.eth0.10andeth0.20are two sub-interfaces on a single physical port, distinguished entirely by their 802.1Q (VLAN) tag. The router can tag the frames just as the switch does. It needs to be able to do so because routing involves re-framing the packet.
If it went wrong
| Symptom | Cause | Fix |
|---|---|---|
| Router reachable in one VLAN only | Ethernet4 is still an access port |
Configure → Ports — it must be type dot1q |
R1 eth0 fails to restart |
Network manager refuses to restart an interface without an address | nmcli con mod eth0 ipv4.method disabled ipv6.method disabled |
| Hosts reach the router but not each other | forwarding off | enable IP forward |
| Trunk capture shows one VLAN untagged | the trunk's VLAN is set to 10 or 20 | set Ethernet4 to VLAN 1 |