Skip to content
VLAN & Trunk Cheat Sheet

VLAN & Trunk Cheat Sheet

The Layer-2 commands I keep reaching for, with the IOS and Junos spelling next to each other. Where a line is marked (IOS) or (Junos) only, the other platform has no direct equivalent.

VLANs

TaskCisco IOSJunos
Create a VLANvlan 20 / name Serversset vlans servers vlan-id 20
List VLANsshow vlan briefshow vlans
VLAN membership of a portshow interfaces statusshow ethernet-switching interfaces

Access ports

! IOS
interface Gi1/0/5
 description Printer
 switchport mode access
 switchport access vlan 20
 spanning-tree portfast
# Junos
set interfaces ge-0/0/5 description Printer
set interfaces ge-0/0/5 unit 0 family ethernet-switching interface-mode access
set interfaces ge-0/0/5 unit 0 family ethernet-switching vlan members servers
set protocols rstp interface ge-0/0/5 edge

Trunk ports

! IOS
interface Gi1/0/48
 description Uplink to core
 switchport trunk encapsulation dot1q   ! older platforms only
 switchport mode trunk
 switchport trunk allowed vlan 10,20,30
 switchport trunk native vlan 999       ! unused VLAN as native
 switchport nonegotiate                 ! no DTP
# Junos
set interfaces ge-0/0/47 description "Uplink to core"
set interfaces ge-0/0/47 unit 0 family ethernet-switching interface-mode trunk
set interfaces ge-0/0/47 unit 0 family ethernet-switching vlan members [ users servers voice ]
set interfaces ge-0/0/47 native-vlan-id 999

Tip

Prune trunks to the VLANs that actually need to cross them, and never leave VLAN 1 as the native VLAN on a trunk that leaves the rack.

Spanning tree

TaskCisco IOSJunos
Modespanning-tree mode rapid-pvstset protocols rstp (default on EX)
Root bridgespanning-tree vlan 1-4094 priority 4096set protocols rstp bridge-priority 4k
Edge portspanning-tree portfastset protocols rstp interface ge-0/0/5 edge
Protect edge portsspanning-tree bpduguard enableset protocols rstp bpdu-block-on-edge
Statusshow spanning-tree / show spanning-tree rootshow spanning-tree bridge / show spanning-tree interface

Port channels

! IOS - LACP
interface range Gi1/0/1-2
 channel-group 1 mode active
interface Port-channel1
 switchport mode trunk
# Junos - LACP
set chassis aggregated-devices ethernet device-count 2
set interfaces ge-0/0/0 ether-options 802.3ad ae0
set interfaces ge-0/0/1 ether-options 802.3ad ae0
set interfaces ae0 aggregated-ether-options lacp active
set interfaces ae0 unit 0 family ethernet-switching interface-mode trunk

Troubleshooting

WhatCisco IOSJunos
MAC tableshow mac address-tableshow ethernet-switching table
Where is a MAC?show mac address-table address aaaa.bbbb.ccccshow ethernet-switching table | match aa:bb:cc
Neighboursshow cdp neighbors / show lldp neighborsshow lldp neighbors
Errors on a portshow interfaces Gi1/0/5 | include errorshow interfaces ge-0/0/5 extensive | match error
Trunk checkshow interfaces trunkshow ethernet-switching interfaces ge-0/0/47
Last updated on