Switching
VLANs and trunks, explained with the commands you will type
A VLAN splits one physical switch into several separate layer 2 networks. Hosts in VLAN 10 cannot talk to hosts in VLAN 20 without a router, even when they plug into the same switch.
Access ports and trunk ports
- An access port belongs to exactly one VLAN and sends frames untagged. It is where end devices connect.
- A trunk port carries several VLANs at once between switches, adding an 802.1Q tag so the far end knows which VLAN each frame belongs to.
Configuring both
SW1(config)# vlan 10
SW1(config-vlan)# name STAFF
SW1(config)# interface g0/2
SW1(config-if)# switchport mode access
SW1(config-if)# switchport access vlan 10
SW1(config)# interface g0/1
SW1(config-if)# switchport mode trunk
SW1(config-if)# switchport trunk allowed vlan 10,20Check your work
SW1# show vlan brief
SW1# show interfaces trunkshow vlan brief lists each VLAN and the access ports in it. show interfaces trunk lists the trunk ports, the VLANs they allow and the native VLAN. Most trunk problems come from a mismatched native VLAN or a VLAN missing from the allowed list.
The native VLAN
Frames in the native VLAN cross a trunk untagged. Both ends of a trunk must agree on it, which is why a mismatch is a favourite troubleshooting question.
Put it into practice: the drill gives you a fresh question every time and explains each miss.
Try a drill