What's your name?

Enter your name to start a short security demo.

Blog

Step-by-Step: Inter-VLAN Routing on Cisco (Router-on-a-Stick)

In the previous VLAN tutorial, we learned how to split a network into isolated logical segments. But the next question is: what if the sales department (VLAN 10) sometimes needs to communicate with finance (VLAN 20)? That's where Inter-VLAN Routing comes in. The most common and simplest way to do this is the Router-on-a-Stick technique.

What exactly is Router-on-a-Stick?
Instead of dedicating a separate physical router port to each VLAN (which isn't practical as VLANs grow), we connect just one router port to the switch and split that port into several logical sub-interfaces — each sub-interface handling one VLAN.

Step 1: Configure the switch port as a trunk
The port connecting the switch to the router needs to be a trunk so it can carry traffic for all VLANs:
enable
configure terminal
interface fastEthernet 0/1
switchport trunk encapsulation dot1q
switchport mode trunk
exit

Step 2: Enter router configuration
Now from the router:
enable
configure terminal

Step 3: Create a sub-interface for the first VLAN
For VLAN 10 (Sales):
interface fastEthernet 0/0.10
encapsulation dot1Q 10
ip address 192.168.10.1 255.255.255.0
exit

The encapsulation dot1Q 10 command specifies that this sub-interface handles traffic tagged with VLAN 10. The IP address you enter becomes the default gateway for devices in that VLAN.

Step 4: Create a sub-interface for the second VLAN
For VLAN 20 (Finance):
interface fastEthernet 0/0.20
encapsulation dot1Q 20
ip address 192.168.20.1 255.255.255.0
exit

Step 5: Enable the router's main port
The main physical port (fastEthernet 0/0) that these sub-interfaces are defined on also needs to be enabled (no shutdown):
interface fastEthernet 0/0
no shutdown
exit

Step 6: Set the default gateway on clients
On computers in each VLAN, the default gateway must be exactly the corresponding sub-interface's IP — VLAN 10 computers should have 192.168.10.1 and VLAN 20 computers should have 192.168.20.1 as their gateway.

Step 7: Test connectivity
From a computer in VLAN 10, ping a computer in VLAN 20:
ping 192.168.20.10

If you get a reply, Inter-VLAN Routing has been configured successfully, and the two separate logical networks are now communicating through the router.

This is exactly the combination of VLANs and routing used constantly in real enterprise network scenarios — and it's practiced in full, hands-on detail in my CCNA courses.