Objective
Configure a Router and Switch to allow communication between VLAN 10 and VLAN 20 using sub-interfaces.
Lab Topology
R1 (Gi0/0) connected to SW1 (Gi0/1)
VLAN 10: 192.168.10.0/24 | VLAN 20: 192.168.20.0/24
Task 1 – Switch Configuration
Create VLANs and configure the trunk link to the router.
SW1(config)# vlan 10 SW1(config)# vlan 20 SW1(config)# interface gigabitEthernet 0/1 SW1(config-if)# switchport mode trunk SW1(config-if)# no shutdown
Task 2 – Router Sub-interfaces
Configure sub-interfaces for each VLAN with 802.1Q encapsulation.
R1(config)# interface gigabitEthernet 0/0 R1(config-if)# no shutdown R1(config-if)# exit R1(config)# interface gigabitEthernet 0/0.10 R1(config-subif)# encapsulation dot1q 10 R1(config-subif)# ip address 192.168.10.1 255.255.255.0 R1(config)# interface gigabitEthernet 0/0.20 R1(config-subif)# encapsulation dot1q 20 R1(config-subif)# ip address 192.168.20.1 255.255.255.0
Task 3 – Verification
Verify the routing table contains both subnets.
R1# show ip route connected C 192.168.10.0/24 is directly connected, GigabitEthernet0/0.10 C 192.168.20.0/24 is directly connected, GigabitEthernet0/0.20