Sub topic 3
Routing Between VLANs
Assume you know Ethernet switching, IPv4 subnets, and basic switch configuration. A VLAN is a Layer 2 broadcast domain. Hosts in different VLANs need a router or Layer 3 switch to communicate.
Routing between VLANs
With router-on-a-stick, one router interface connects to a trunk. Each subinterface represents one VLAN and acts as that VLAN's default gateway.
interface GigabitEthernet0/0
no shutdown
!
interface GigabitEthernet0/0.10
encapsulation dot1Q 10
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.0A Layer 3 switch can instead use a switched virtual interface (SVI), which is a virtual routed interface for a VLAN. SVIs usually provide better performance and simpler scaling than one router link.
Voice VLANs on access ports
A phone and a computer can share one switch port. The phone uses a voice VLAN, while the computer uses the data VLAN. The phone commonly sends tagged voice frames, and the attached computer sends untagged data frames.
interface GigabitEthernet0/5
switchport mode access
switchport access vlan 10
switchport voice vlan 30Tagging overhead and frame size
An 802.1Q tag adds 4 bytes between the source MAC address and EtherType. A tagged Ethernet frame can therefore be 4 bytes larger than an untagged frame. Check the supported maximum frame size when connecting devices or carrying encapsulated traffic.
VLAN hopping: switch spoofing and double tagging
In switch spoofing, an attacker sends trunk-negotiation traffic to make an access port become a trunk. In double tagging, an attacker adds two VLAN tags so an outer tag is removed on a native-VLAN trunk, exposing the inner tag.
Mitigate these attacks by forcing user ports to access mode, disabling DTP, using an unused native VLAN, and allowing only required VLANs on trunks.
Verifying and troubleshooting
show vlan brief
show interfaces trunk
show interfaces GigabitEthernet0/24 switchportCheck that the VLAN exists, the port has the intended mode, both trunk ends use the same native VLAN, and the required VLAN appears in the allowed list. Also verify that the endpoint's default gateway points to the correct SVI or router subinterface.
Q-in-Q: stacking tags
Q-in-Q, or 802.1ad, adds an outer VLAN tag around an existing customer tag. Service providers can carry many customer VLANs through their network while preserving each customer's inner VLAN information.
Exercise
A host in VLAN 10 cannot reach a host in VLAN 20. What should you check first?
Show answer
Verify that both VLANs exist, the trunk allows both VLANs, the native VLAN matches, and each host uses the correct routed gateway.