Hands-On Lab: Configuring Inter-VLAN Routing (Router on a Stick)

This hands-on lab configures inter-VLAN routing using a single router interface divided into subinterfaces, connecting to a switch trunk to route traffic between two VLANs through one physical link.

Router on a StickSubinterface Configuration802.1Q Encapsulation

~3 دقیقه مطالعه · آخرین به‌روزرسانی ۳۱ شهریور ۱۴۰۵

Lab Objective

Configure a router with two subinterfaces on a single physical interface, connect it to a switch trunk carrying two VLANs, and verify hosts in each VLAN can reach each other through the router.

Lab Purpose

Before a Layer 3 switch with SVIs is available or justified, router-on-a-stick remains a common, simple way to enable inter-VLAN routing using a single router interface and a trunk link, especially in smaller networks or lab environments.

Lab Topology

R1 ---- Gi0/0 (trunk) ---- Switch1

Switch1:
  Gi1/0/1 ---- PC-A (VLAN 10): 192.168.10.10/24
  Gi1/0/2 ---- PC-B (VLAN 20): 192.168.20.10/24
  Gi1/0/24 ---- trunk to R1

R1 subinterfaces:
  Gi0/0.10: 192.168.10.1/24 (VLAN 10)
  Gi0/0.20: 192.168.20.1/24 (VLAN 20)

Task 1: Configure the Switch Trunk and VLANs

Create VLANs 10 and 20 on Switch1, assign Gi1/0/1 to VLAN 10 and Gi1/0/2 to VLAN 20, and configure Gi1/0/24 as a trunk allowing both VLANs.

Task 2: Configure the Router's Physical Interface

Bring up Gi0/0 on R1 without assigning it an IP address directly.

Task 3: Configure the Subinterfaces

Create subinterfaces Gi0/0.10 and Gi0/0.20 with appropriate 802.1Q encapsulation and IP addresses.

Task 4: Configure PC Default Gateways

Set PC-A's default gateway to R1's Gi0/0.10 address, and PC-B's to Gi0/0.20's address.

Task 5: Verify Inter-VLAN Connectivity

Confirm PC-A can ping PC-B across the two VLANs.

Solution and Verification

Switch1(config)# vlan 10
Switch1(config-vlan)# exit
Switch1(config)# vlan 20
Switch1(config-vlan)# exit

Switch1(config)# interface gigabitethernet1/0/1
Switch1(config-if)# switchport mode access
Switch1(config-if)# switchport access vlan 10
Switch1(config-if)# exit

Switch1(config)# interface gigabitethernet1/0/2
Switch1(config-if)# switchport mode access
Switch1(config-if)# switchport access vlan 20
Switch1(config-if)# exit

Switch1(config)# interface gigabitethernet1/0/24
Switch1(config-if)# switchport mode trunk

R1(config)# interface gigabitethernet0/0
R1(config-if)# no shutdown
R1(config-if)# exit

R1(config)# interface gigabitethernet0/0.10
R1(config-subif)# encapsulation dot1Q 10
R1(config-subif)# ip address 192.168.10.1 255.255.255.0
R1(config-subif)# exit

R1(config)# interface gigabitethernet0/0.20
R1(config-subif)# encapsulation dot1Q 20
R1(config-subif)# ip address 192.168.20.1 255.255.255.0

PC-A: default gateway 192.168.10.1
PC-B: default gateway 192.168.20.1

PC-A> ping 192.168.20.10

Reply from 192.168.20.10: bytes=32 time=2ms

R1# show ip route

C    192.168.10.0/24 is directly connected, GigabitEthernet0/0.10
C    192.168.20.0/24 is directly connected, GigabitEthernet0/0.20

Key Takeaway

Each subinterface's encapsulation dot1Q command must exactly match the VLAN number carried on the corresponding trunk tag — forgetting this command, or specifying the wrong VLAN number, is the most common cause of a router-on-a-stick configuration that appears correct but fails to route traffic for that specific VLAN.

نوشته و پژوهش‌شده توسط دکتر شاهین صیامی

مقالات مرتبط

Hands-On Lab: Final Comprehensive CCNP Troubleshooting Challenge (BGP, DMVPN, and QoS Integration)

This hands-on lab presents a complex multi-layer failure across an integrated BGP-over-DMVPN topology combined with QoS marking, requiring systematic diagnosis of a route reflector misconfiguration, an NHRP registration failure, and an incorrectly applied QoS policy simultaneously affecting the same network.

ادامه

Hands-On Lab: Configuring BGP over DMVPN

This hands-on lab runs iBGP as the routing protocol across the same DMVPN hub-and-spoke topology used in the two previous labs, configuring the hub as a route reflector so spokes learn each other's routes without a full iBGP mesh, combining two previously separate concepts into one integrated design.

ادامه

Hands-On Lab: Configuring OSPF over DMVPN

This hands-on lab runs OSPF as the dynamic routing protocol across the same DMVPN hub-and-spoke topology, configuring the tunnel interface as an OSPF point-to-multipoint network type to correctly handle the hub-and-spoke adjacency pattern without requiring the broadcast network type's DR/BDR election.

ادامه

Hands-On Lab: Configuring EIGRP over DMVPN

This hands-on lab runs EIGRP as the dynamic routing protocol across the DMVPN hub-and-spoke topology built in earlier labs, verifying neighbor relationships form correctly across the multipoint tunnel and routes propagate without requiring per-spoke static configuration on the hub.

ادامه

Hands-On Lab: Configuring HSRP MD5 Authentication

This hands-on lab configures MD5 authentication on an HSRP group, verifying two routers with matching authentication strings form a normal active/standby relationship while a router with a mismatched string is excluded from the group entirely.

ادامه

Hands-On Lab: Configuring Cisco Umbrella-Style DNS Security via DNS Forwarding Redirection

This hands-on lab configures a router to redirect all client DNS queries toward a security-focused DNS resolver using DNS forwarding interception, approximating cloud-delivered DNS security enforcement without requiring per-client configuration changes.

ادامه