VLAN, Trunking, and Inter-VLAN Routing
(Router-on-a-Stick)
Introduction
This document explains VLANs, trunking, and inter-VLAN routing using a router-on-a-stick
topology. The goal is to divide a network into logical segments while still allowing
controlled communication between them using a router.
Main Switch Configuration
The main switch acts as the central aggregation point. It connects all department switches
and the router. VLANs are created here and trunk links are established to carry multiple
VLANs.
VLAN Creation
vlan 10
name IT
vlan 20
name HR
vlan 30
name FINANCE
These commands create three VLANs representing IT, HR, and Finance. VLAN IDs are used
in tagging to identify traffic.
Trunk Ports to Department Switches
interface range fa0/1 - 3
switchport mode trunk
switchport trunk allowed vlan 10,20,30
no shutdown
These ports connect to other switches. Trunk mode allows multiple VLAN traffic to pass
using tagging.
Trunk Port to Router
interface fa0/24
switchport mode trunk
switchport trunk allowed vlan 10,20,30
no shutdown
This link carries all VLAN traffic to the router for inter-VLAN routing.
IT Switch Configuration
The IT switch handles only VLAN 10 for end devices while using a trunk uplink to the main
switch.
Access Ports for IT Devices
interface range fa0/1 - 10
switchport mode access
switchport access vlan 10
no shutdown
These ports assign connected devices to VLAN 10. Devices do not understand VLAN tags, so
access mode is used.
Uplink Trunk Port
interface fa0/24
switchport mode trunk
switchport trunk allowed vlan 10,20,30
no shutdown
This trunk carries VLAN traffic to the main switch.
HR Switch Configuration
The HR switch is configured similarly but uses VLAN 20.
Access Ports for HR Devices
interface range fa0/1 - 10
switchport mode access
switchport access vlan 20
no shutdown
Uplink Trunk Port
interface fa0/24
switchport mode trunk
switchport trunk allowed vlan 10,20,30
no shutdown
Finance Switch Configuration
The Finance switch uses VLAN 30 for its devices.
Access Ports for Finance Devices
interface range fa0/1 - 10
switchport mode access
switchport access vlan 30
no shutdown
Uplink Trunk Port
interface fa0/24
switchport mode trunk
switchport trunk allowed vlan 10,20,30
no shutdown
Router Configuration (Router-on-a-Stick)
The router performs inter-VLAN routing using subinterfaces. Each subinterface represents
a VLAN and acts as its default gateway.
Enable Physical Interface
interface fa0/0
no shutdown
This activates the physical link. Without this, no communication is possible.
Subinterfaces for VLANs
interface fa0/0.10
encapsulation dot1Q 10
ip address [Link] [Link]
interface fa0/0.20
encapsulation dot1Q 20
ip address [Link] [Link]
interface fa0/0.30
encapsulation dot1Q 30
ip address [Link] [Link]
Each subinterface is bound to a VLAN using 802.1Q tagging. The IP address assigned
becomes the default gateway for that VLAN.