VLAN and Trunking Configuration
VLAN creation and assignment: on a managed switch, create VLANs and assign access ports to VLANs. Access port: carries traffic for a single VLAN, untagged — connected to end devices (computers, printers, phones). The switch adds and removes the 802.1Q tag transparently to the end device. Trunk port: carries tagged traffic for multiple VLANs on a single link — used between switches and between switch and router.
802.1Q trunking: adds a 4-byte VLAN tag to Ethernet frames (12-bit VLAN ID, allowing VLANs 1–4094). Native VLAN: the VLAN that is untagged on a trunk port — frames from the native VLAN are sent without a tag. Native VLAN must match on both ends of a trunk — mismatch causes traffic to cross into the wrong VLAN (native VLAN mismatch vulnerability).
DTP (Dynamic Trunking Protocol): Cisco proprietary, automatically negotiates trunk links. Modes: auto (passive, waits for negotiation), desirable (actively negotiates), trunk (always trunk), access (always access). Security: disable DTP on access ports with 'switchport nonegotiate' — prevents unauthorized trunk negotiation. Always configure port mode explicitly; do not rely on DTP in production.
VTP (VLAN Trunking Protocol): Cisco proprietary, synchronizes VLAN databases between switches in a VTP domain. Modes: server (creates/modifies VLANs, propagates), client (receives, cannot modify), transparent (local only, forwards but ignores VTP), off. VTP can cause catastrophic VLAN deletion if a switch with a higher revision number propagates an empty VLAN database — understand VTP risks.
Port Security and Layer 2 Security
Port security: limits which MAC addresses can use a switch port. Maximum MAC addresses per port: configurable (1 for a single device, more for IP phones with attached computers). Violation modes: protect (drop, no notification), restrict (drop + SNMP trap/syslog), shutdown (err-disable the port — must be manually re-enabled or auto-recovery configured).
Sticky MAC: port security learns and saves the MAC address of the first device to connect — automatically creates a secure MAC entry without manual configuration. Combined with violation mode shutdown: if a different device connects, the port shuts down. Provides easy per-port device locking.
DHCP snooping: validates DHCP messages on untrusted ports. Trusted ports: uplinks to legitimate DHCP servers. Untrusted ports: all access ports. Drops DHCP Offer and DHCP Acknowledgment messages arriving on untrusted ports — prevents rogue DHCP servers. Builds a binding table (MAC, IP, port, VLAN) used by Dynamic ARP Inspection.
Dynamic ARP Inspection (DAI): validates ARP messages against the DHCP snooping binding table. ARP packets with unexpected MAC/IP mappings are dropped — prevents ARP spoofing and ARP cache poisoning. Works in conjunction with DHCP snooping.
802.1X port-based access control: devices must authenticate (EAP over LAN — EAPOL) before the switch port allows network access. The switch (authenticator) forwards credentials to a RADIUS server. Unauthenticated devices are in a restricted VLAN or blocked entirely. Prevents unauthorized devices from connecting to the network.
STP and Redundancy Configuration
Spanning Tree Protocol (STP 802.1D): prevents Layer 2 loops by blocking redundant paths. States: blocking, listening, learning, forwarding, disabled. Root bridge election: lowest bridge priority wins (default 32768 + VLAN); tie broken by lowest MAC. Root ports: port with best path to root bridge. Designated ports: best port on each segment. Non-designated ports: blocked.
Rapid STP (RSTP 802.1w): faster convergence than STP. New port roles: Alternate (backup for root port) and Backup (backup for designated port). Edge ports (connected to end devices) move directly to forwarding without waiting — configure with PortFast. RSTP converges in 1–2 seconds vs STP's 30–50 seconds.
PortFast: enables edge ports to skip STP listening/learning states and go directly to forwarding. Only enable on ports connected to end devices (not switches) — enabling PortFast on switch-to-switch links can create loops. BPDU Guard: if a BPDU is received on a PortFast port, immediately err-disable the port — prevents unauthorized switch connection on access ports.
Loop Guard and Root Guard: Loop Guard prevents alternate ports from becoming designated ports if BPDUs stop arriving (prevents loops from unidirectional link failures). Root Guard prevents a port from becoming the root port — keeps the root bridge location controlled.