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.
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
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 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.