CCNA · Lesson 9 of 13

Inter-VLAN Routing with Router-on-a-Stick

VLANs separate traffic. But when Sales needs to reach the Accounting server, someone has to route.

By topologia.appUpdated: Nov 13, 2026⏱ 5 min❓ 4 questions📶 Level beginner

In a nutshell

A router with a single physical interface, split into subinterfaces (one per VLAN), routes traffic between VLANs over a trunk.

In this lesson
  1. The idea
  2. Router configuration
  3. Switch configuration
  4. Pros and cons
  5. Verify
  6. What you must remember
  7. Exam-style questions

The idea

Each VLAN is a different subnet. Moving from one subnet to another requires a router. Each PC uses the router IP in its VLAN as its default gateway.

In router-on-a-stick (ROAS), the router uses a single physical interface connected to a trunk. That interface is split into subinterfaces, one per VLAN, each with its own IP.

Router-on-a-stick: R1 connected to SW1 over a trunk, with PC1 in VLAN 10 and PC2 in VLAN 20 TRUNK 802.1Q G0/0G0/1 R1 SW1 PC1 · VLAN 10 PC2 · VLAN 20 G0/0.10 → 192.168.10.1G0/0.20 → 192.168.20.1 Gateway PC1: 192.168.10.1Gateway PC2: 192.168.20.1 10 20
Follow the dot: PC1 sends to its gateway → it goes up the trunk tagged 10 → R1 routes → it comes back down tagged 20 → it reaches PC2.Edit in the editor ↗

Router configuration

R1(config)# interface g0/0
R1(config-if)# no shutdown  ← the physical interface is enabled and has no IP
R1(config)# interface g0/0.10
R1(config-subif)# encapsulation dot1Q 10  ← always BEFORE the IP
R1(config-subif)# ip address 192.168.10.1 255.255.255.0
R1(config)# interface g0/0.20
R1(config-subif)# encapsulation dot1Q 20
R1(config-subif)# ip address 192.168.20.1 255.255.255.0

The subinterface number (.10) is just a name; what really binds it to the VLAN is encapsulation dot1Q 10. Using the same number keeps things tidy.

For the native VLAN, add the native keyword: encapsulation dot1Q 99 native.

Switch configuration

SW1(config)# interface g0/1
SW1(config-if)# switchport mode trunk  ← the port towards the router MUST be a trunk

Pros and cons

Pros

Cheap: one router port serves many VLANs. Easy to understand and to build in a lab.

Cons

All inter-VLAN traffic goes through one cable (bottleneck) and a single point of failure.

Verify

R1# show ip interface brief
Interface      IP-Address      OK? Method Status   Protocol
Gi0/0          unassigned      YES unset  up       up
Gi0/0.10       192.168.10.1    YES manual up       up
Gi0/0.20       192.168.20.1    YES manual up       up

What you must remember

  • One physical router interface, one subinterface per VLAN.
  • encapsulation dot1Q <VLAN> goes before the IP.
  • The switch port towards the router must be a trunk.
  • Each PC gateway is the IP of its subinterface.

Check what you learned

4 exam-style questions. Some have one answer and others ask you to choose several. Answer them all to complete the lesson.

Question 1 of 4 · One answerRefer to the configuration. PC1 (VLAN 10, gateway 192.168.10.1) cannot ping PC2 in VLAN 20. The switch port towards R1 is a trunk and the VLANs exist. What is the cause?

Exhibit

R1# show running-config | section GigabitEthernet0/0
interface GigabitEthernet0/0.10
 encapsulation dot1Q 20
 ip address 192.168.10.1 255.255.255.0
!
interface GigabitEthernet0/0.20
 encapsulation dot1Q 20
 ip address 192.168.20.1 255.255.255.0
Question 2 of 4 · One answerIn a router-on-a-stick design, how must the switch port connected to the router be configured?
Question 3 of 4 · Choose twoVLAN 30 (192.168.30.0/24) is added. After creating subinterface G0/0.30, which two commands are needed on it? (Choose two.)
Question 4 of 4 · One answerWhich address must be configured as the default gateway on a PC in VLAN 10?