Python · SQL · Web Dev · Java · AI/ML tracks launching soon — your one platform for all of IT

VLANs — Virtual Network Segmentation

VLANs let you carve one physical switch fabric into multiple isolated broadcast domains. The foundation of every secure, scalable enterprise network — from the office to hyperscale data centers.

22–30 min May 2026

// CHAPTER 01

The Flat Network Catastrophe

// REAL-WORLD SCENARIOIt is 1998. A hospital in Ohio has 400 devices on a single Ethernet segment — workstations, medical imaging machines, printers, nurses' stations. One Monday morning, someone plugs in a misconfigured PC that starts flooding the network with broadcast packets. Within three minutes, every device on the floor stops responding. Monitors flatline — not patients, but the network monitors. Clinicians cannot access patient records. The culprit? A flat network with a single broadcast domain. Every device had to process every broadcast from every other device. The whole fabric choked. The fix took weeks of physical rewiring. A year later, IEEE 802.1Q was finalized. VLANs were born out of necessity.

In the early days of Ethernet, every device on a LAN shared the same broadcast domain. Every ARP request, every DHCP discover, every NetBIOS name resolution — every single one of these frames was sent to every device on the network simultaneously. With 20 computers this was tolerable. With 400 devices, broadcasts consumed significant bandwidth and CPU cycles on every endpoint. With 1,000 devices, network-wide broadcast storms could render the entire segment unusable.

The deeper problem was security. A flat network gives every device direct Layer 2 access to every other device. The accounting server sits on the same broadcast domain as the receptionist's PC. The hospital's imaging machines share a network with the administrative desktops. There is no boundary, no checkpoint. Anyone who can physically plug into any switch port can reach anything.

The traditional solution was physical segmentation: buy more routers, run more cabling, create separate physical networks for each department. Finance gets its own switch and router interface, Engineering gets another, Servers get a third. This worked but was brutally expensive, inflexible (moving a desk meant rewiring), and required significant capital expenditure for each new segment.

The Virtual Solution

IEEE 802.1Q (1998) defined a standard for Virtual LANs — logical broadcast domains that are independent of physical topology. A VLAN is software-defined: the switch administrator assigns each port to a VLAN ID, and the switch enforces isolation between VLANs in hardware. One physical switch can simultaneously carry dozens of isolated VLANs. Hosts in the same room can be in different VLANs (isolated from each other), while hosts in different buildings can be in the same VLAN (as if directly connected).

🏗️From 4,094 VLANs to 16 Million with VXLAN
The 12-bit VLAN ID field in 802.1Q theoretically supports 4,096 unique VLANs per physical domain (IDs 0 and 4095 are reserved, leaving 4,094 usable). But modern hyperscale data centers using VXLAN (Virtual Extensible LAN) extend this to 16 million unique segments using 24-bit VNI (VXLAN Network Identifier) — a 4,000× expansion needed to support multi-tenant cloud environments.

The only way traffic can cross VLAN boundaries is through a Layer 3 device — a router or a Layer 3 switch. This creates a natural security enforcement point: all inter-segment traffic must pass through a router or firewall, where access control lists (ACLs) or firewall policies can inspect, permit, or deny every flow. VLANs transform security from "physical location" to "software-defined policy."

Interactive — VLAN Segmentation Lab

Click a VLAN to inspect it, or use the traffic simulator below.

VLAN 1010.10.10.0/24
ENGINEERING
GW: 10.10.10.1
VLAN 2010.10.20.0/24
SALES
GW: 10.10.20.1
VLAN 3010.10.30.0/24
SERVERS
GW: 10.10.30.1
VLAN 9910.10.99.0/24
MGMT
GW: 10.10.99.1

Traffic Path Simulator

// CHAPTER 02

802.1Q Tagging: How Frames Carry VLAN Identity

// REAL-WORLD SCENARIOImagine a warehouse with conveyor belts — all running to the same sorting area. Without labeling, packages get mixed up. The 802.1Q standard solves the same problem for Ethernet frames: it adds a 4-byte label (tag) to each frame as it enters a trunk port, so every switch along the path knows which "conveyor belt" (VLAN) a frame belongs to. When the frame reaches its destination port, the tag is stripped before delivery — the end device never even knows VLANs exist.

Access Ports vs. Trunk Ports

Switch ports operate in two fundamental modes. An access port belongs to exactly one VLAN. Frames arriving on an access port are untagged — the end device (PC, printer, IP phone, server) has no knowledge of VLANs. The switch silently assigns all incoming frames to the configured VLAN and strips any VLAN tag when forwarding out to the end device.

A trunk port carries traffic from multiple VLANs simultaneously. Trunk ports are used to interconnect switches, connect to routers for inter-VLAN routing, and connect to hypervisors that host VMs in different VLANs. Frames on trunk ports carry an 802.1Q tag identifying which VLAN they belong to. The administrator configures an "allowed VLAN list" on each trunk — VLANs not in this list are pruned (blocked) from the trunk.

The 802.1Q Tag Structure

The 802.1Q standard inserts a 4-byte tag into the Ethernet frame header, inserted between the source MAC address and the original EtherType field. This makes 802.1Q-tagged frames slightly larger than standard Ethernet frames (1522 bytes max vs. 1518 bytes). The tag contains four fields:

TPID (Tag Protocol Identifier) — 2 bytes, always 0x8100. This identifies the frame as 802.1Q tagged. Devices that don't understand VLANs see 0x8100 as an unknown EtherType and may drop the frame — this is intentional.

TCI (Tag Control Information) — 2 bytes comprising three sub-fields: 3-bit PCP (Priority Code Point, 0–7 for 802.1p QoS marking), 1-bit DEI (Drop Eligible Indicator, frames may be discarded under congestion), and 12-bit VID (VLAN Identifier) ranging from 0 to 4095.

Interactive — 802.1Q Frame Inspector

Click any field to inspect it. Configure VID and PCP below.

Dst MAC
6B
Src MAC
6B
TPID
2B
TCI
2B
EtherType
2B
Payload
8B
FCS
4B

Total frame overhead with 802.1Q tag: 30 bytes (4 bytes added vs. untagged)

TCI Field Breakdown (16 bits)

PCP
3b
DEI
1b
VID
12b

Build Your TCI

TCI hex value

0x000A

The Native VLAN

On a trunk port, one VLAN is designated the native VLAN. Frames from the native VLAN are sent untagged across the trunk (for backward compatibility with older untagged equipment). Untagged frames received on a trunk port are assigned to the native VLAN. By default on Cisco equipment, VLAN 1 is the native VLAN.

Native VLAN mismatchIf the native VLAN differs between two ends of a trunk link (e.g., VLAN 1 on Switch A, VLAN 10 on Switch B), untagged frames will be misassigned — frames intended for VLAN 1 will be delivered to VLAN 10. Spanning Tree Protocol may also malfunction. Always verify native VLAN matches on both ends of every trunk link. Use show interfaces trunk on Cisco to audit.
# Cisco IOS — configure access port in VLAN 10
interface GigabitEthernet0/1
  description PC-Engineering-Floor-1
  switchport mode access
  switchport access vlan 10
  spanning-tree portfast

# Cisco IOS — configure trunk port between switches
interface GigabitEthernet0/24
  description Trunk-to-SW-DIST-01
  switchport mode trunk
  switchport trunk encapsulation dot1q
  switchport trunk native vlan 999
  switchport trunk allowed vlan 10,20,30,99

Dynamic Trunking Protocol (DTP)

Cisco's proprietary DTP automatically negotiates trunk formation between switches. A port in "dynamic desirable" mode will actively try to form a trunk; "dynamic auto" will form a trunk if the other end initiates. While convenient in small labs, DTP is a security risk in production: an attacker can plug in a device that sends DTP frames, causing the switch port to trunk up, potentially exposing all VLANs.

Best practice: explicitly set every port to either switchport mode access or switchport mode trunk, and disable DTP negotiation on trunk ports with switchport nonegotiate. Never rely on auto-negotiation for security-sensitive switch ports.

// CHAPTER 03

Inter-VLAN Routing: Crossing Broadcast Domains

// REAL-WORLD SCENARIOYour VLAN architecture is perfect — Engineering can't reach Finance, Finance can't reach Servers. But then an Engineering developer needs to access the database server in the Servers VLAN. How? VLANs are Layer 2 isolation; crossing them requires Layer 3. This is where routers and Layer 3 switches enter the picture.

Router-on-a-Stick

The classic method uses a single router physical interface connected to a trunk port. The router creates logical sub-interfaces, each encapsulating a different VLAN tag and configured with the gateway IP for that VLAN. All inter-VLAN traffic must exit the switch, travel up to the router's single uplink, get routed, and return on the same trunk link.

# Cisco IOS — router-on-a-stick configuration
interface GigabitEthernet0/0.10
  encapsulation dot1q 10
  ip address 10.10.10.1 255.255.255.0

interface GigabitEthernet0/0.20
  encapsulation dot1q 20
  ip address 10.10.20.1 255.255.255.0

interface GigabitEthernet0/0.30
  encapsulation dot1q 30
  ip address 10.10.30.1 255.255.255.0

Router-on-a-stick works well for small networks and labs. The limitation is bandwidth: all inter-VLAN traffic shares the single uplink's capacity. If the link is 1 Gbps and you have Engineering at 200 Mbps, Sales at 150 Mbps, and Servers at 400 Mbps all simultaneously doing inter-VLAN transfers, you've already saturated the uplink.

Layer 3 Switches and SVIs

Modern enterprise networks use Layer 3 switches for inter-VLAN routing. A Switched Virtual Interface (SVI) is a logical Layer 3 interface for each VLAN on the switch itself. Each SVI has an IP address that serves as the default gateway for that VLAN. Routing between SVIs happens in the switch's hardware ASICs using the FIB (Forwarding Information Base), at line rate.

The performance difference is dramatic. Router-on-a-stick with software routing: ~50 µs per-packet latency. Layer 3 switch ASIC routing: ~1–3 µs. A Cisco Catalyst 9300 can route 200+ million packets per second across SVIs in hardware — orders of magnitude beyond what any router can achieve on the same budget.

# Cisco IOS — Layer 3 switch with SVIs
ip routing

interface Vlan10
  description Engineering Gateway
  ip address 10.10.10.1 255.255.255.0
  no shutdown

interface Vlan20
  description Sales Gateway
  ip address 10.10.20.1 255.255.255.0
  no shutdown

interface Vlan30
  description Servers Gateway
  ip address 10.10.30.1 255.255.255.0
  no shutdown

interface Vlan99
  description Management Gateway
  ip address 10.10.99.1 255.255.255.0
  no shutdown

CEF and the Hardware Fast Path

Cisco's CEF (Cisco Express Forwarding) pre-builds a hardware FIB from the software routing table. After the first packet of a new flow is processed in software (the "process switching" path), CEF installs a flow entry and subsequent packets are switched entirely in hardware without CPU involvement. This is called fast-path or hardware switching.

Modern switch ASICs go further: ternary content-addressable memory (TCAM) allows parallel lookups across all FIB entries in a single clock cycle, regardless of table size. A 100,000-entry routing table and a 10-entry routing table have identical lookup latency in TCAM hardware.

// CHAPTER 04

VTP, Private VLANs, and Advanced Segmentation

VLAN Trunking Protocol (VTP)

// REAL-WORLD SCENARIOYou manage 50 switches across a campus. You need to add VLAN 50 for a new department. Without VTP, you SSH into each of 50 switches and type the same VLAN commands. With VTP, you add it once on the Server switch and it propagates automatically. Sounds perfect — until someone brings in a switch from another site with a higher VTP revision number. Within seconds, that switch's VLAN database overwrites yours across every switch in the campus, deleting every VLAN. Everything goes dark.

Cisco's proprietary VTP synchronizes VLAN databases across all switches in a VTP domain. The VTP Server holds the authoritative VLAN database; Client switches receive updates and propagate them. The revision number determines precedence — the switch with the highest revision wins.

The danger: any switch can be brought in from another deployment, lab environment, or storage with a higher revision number. Plugging it in propagates its (possibly empty or outdated) VLAN database to the entire campus instantly, dropping all active VLANs and crashing the network. This has caused production outages at Fortune 500 companies.

VTP Server mode in productionMost experienced network engineers configure all switches to vtp mode transparent (propagates VTP frames without acting on them) or use VTP version 3 with a primary server requiring explicit promotion before changes propagate. The convenience of VTP Server mode rarely justifies the risk of an accidental database wipe.

Private VLANs (PVLANs)

Private VLANs (IEEE 802.1Q-2003 extension) add isolation within a VLAN. Used primarily in hosting environments where multiple customers share a VLAN but must be isolated from each other. The PVLAN structure uses a primary VLAN containing secondary VLANs:

Promiscuous port — can communicate with all ports in all secondary VLANs. Typically the uplink to the router or gateway.

Isolated port — can only communicate with the promiscuous port. Two isolated ports in the same PVLAN cannot reach each other directly.

Community port — can communicate with other ports in the same community and with the promiscuous port, but not with isolated ports or other communities.

A typical web hosting scenario: all customer web servers are in an isolated secondary VLAN, sharing one IP subnet (e.g., 192.168.1.0/24). They can all reach the gateway (promiscuous port) for internet access, but they cannot reach each other directly — even though they share the same subnet. This prevents one compromised server from attacking others via Layer 2 techniques.

QinQ (IEEE 802.1ad)

QinQ stacks two 802.1Q tags in a single frame: an outer S-Tag (Service VLAN, 0x88a8) and an inner C-Tag (Customer VLAN, 0x8100). Service providers use QinQ to transparently carry customer VLANs across a provider backbone.

The math: 4,094 usable S-Tags × 4,094 usable C-Tags ≈ 16.7 million unique combinations. This effectively eliminates VLAN ID conflicts between customers — each customer can use VLAN IDs 1–4094 internally without interfering with other customers using the same IDs. The provider's backbone only sees the S-Tag; the C-Tag is opaque.

VXLAN — VLANs at Cloud Scale

Enterprise VLANs max out at 4,094 segments. AWS, Azure, and Google Cloud run millions of isolated tenant networks simultaneously — 4,094 VLANs is laughably insufficient. VXLAN (Virtual Extensible LAN, RFC 7348) solves this by encapsulating Layer 2 Ethernet frames inside UDP packets. The VXLAN header contains a 24-bit VNI (VXLAN Network Identifier), supporting 16,777,216 unique virtual networks.

Each hypervisor runs a VTEP (VXLAN Tunnel Endpoint) that encapsulates/decapsulates VXLAN traffic. From the VM's perspective, it's on a flat Layer 2 network. From the physical network's perspective, it's all just UDP traffic on port 4789. VXLAN enables VM mobility across physical racks, rows, and even data centers while maintaining Layer 2 adjacency.

☁️AWS VPC Is a Hyperscale VXLAN Fabric
AWS's internal network fabric — Nitro — uses a proprietary overlay similar to VXLAN. Every EC2 instance runs in an isolated VPC (Virtual Private Cloud) that is fundamentally a VXLAN-like virtual network. When you create an AWS VPC with subnets, you're provisioning what is essentially a software-defined VLAN spanning the entire AWS region's physical fabric — hundreds of thousands of servers across dozens of availability zones.

// CHAPTER 05

VLAN Security: Threats and Defenses

VLAN Hopping via Double-Tagging

The most famous VLAN attack is double-tagging, exploiting the native VLAN's untagged behavior. An attacker on the native VLAN sends a frame with two 802.1Q tags: the outer tag matches the native VLAN (stripped by the first switch), and the inner tag contains the target VLAN ID. The first switch forwards the frame to the second switch, which sees only the inner tag and delivers it to the victim VLAN.

This attack is unidirectional only — the attacker can send frames into the target VLAN but cannot receive responses (responses would be tagged correctly and not reach the attacker's VLAN). Despite this limitation, it's sufficient to send exploit payloads, ARP packets, or probe for vulnerabilities in the victim VLAN.

Interactive — VLAN Hopping Attack Demo

Step through a double-tagging VLAN hopping attack and its defense.

Select a phase above to walk through the attack.

DTP-Based VLAN Hopping

A simpler form of VLAN hopping exploits DTP. If an attacker connects to a switch port that is in "dynamic auto" or "dynamic desirable" DTP mode, they can send DTP frames causing the switch to negotiate the port into trunk mode. Once the port is a trunk, the attacker can tag frames with any VLAN ID and access any VLAN carried by that trunk.

Mitigation: explicitly configure all end-host ports with switchport mode access and switchport nonegotiate. These two commands together ensure DTP frames are never sent or honored on the port.

MAC Flooding and CAM Table Overflow

A switch maintains a CAM (Content Addressable Memory) table mapping MAC addresses to ports. If an attacker floods the switch with frames containing thousands of fake source MAC addresses, the CAM table fills up and new legitimate MACs cannot be learned. The switch enters fail-open mode, broadcasting all frames to all ports — effectively turning the switch into a hub and allowing the attacker to capture all traffic.

Defense: Port Security limits the number of MAC addresses allowed on a port (e.g., switchport port-security maximum 3). Exceeding the limit triggers an action: protect (drop), restrict (drop + log), or shutdown (disable port). 802.1X authentication provides stronger protection by authenticating devices before allowing network access.

VLAN ACLs (VACLs)

Standard router ACLs filter traffic between VLANs at Layer 3. But what about filtering traffic within a VLAN? VLAN ACLs (VACLs) on Cisco switches apply to all traffic within a VLAN — both routed and bridged. A VACL can block specific protocols, IP addresses, or port numbers between hosts in the same VLAN, where a router ACL would never see the traffic.

// CHAPTER 06

VLANs in the Data Center

// REAL-WORLD SCENARIOImagine a data center with 10,000 servers and 300 tenants (companies). Each tenant needs their own isolated network — their VMs must not be able to talk to another tenant's VMs. With classic 802.1Q VLANs, you'd need 300 VLANs minimum, a reasonable number. But each tenant might need 10–20 sub-segments (web tier, app tier, database tier, management). Suddenly you need 3,000–6,000 VLANs. And that's just one data center. Multiply across 20 availability zones and 6 regions. Classic VLANs collapse. This is why cloud providers use VXLAN and BGP EVPN.

Leaf-Spine and VXLAN Fabric

Modern data centers use a leaf-spine topology. Leaf switches connect to servers; spine switches interconnect all leaves in a full mesh. Every leaf connects to every spine — this guarantees that any server can reach any other server in exactly two hops (leaf → spine → leaf). There is no hierarchy, no bottleneck core.

In a VXLAN-based leaf-spine fabric, each leaf switch is a VTEP. VMs on different leaves that belong to the same VXLAN segment communicate through VXLAN-encapsulated UDP tunnels between VTEPs. The spine layer is pure IP — it has no knowledge of the overlay VLANs. This separation of underlay (IP transport) from overlay (virtual networks) is the key architectural principle.

BGP EVPN Control Plane

BGP EVPN (Ethernet VPN, RFC 7432) is the control plane for VXLAN fabrics. Instead of flooding ARP requests across the fabric (as traditional VLANs do), BGP EVPN distributes MAC and IP binding information between VTEPs using BGP UPDATE messages. When a VM comes online, its local VTEP advertises the MAC/IP to all other VTEPs via BGP. ARP requests are answered locally from a distributed database rather than flooded across the fabric.

This eliminates the flood-and-learn behavior that makes traditional VLANs unscalable. BGP EVPN also enables efficient multi-site connectivity, VM live migration with preserved MAC/IP bindings, and consistent policy application across data center fabrics.

Microsegmentation

Traditional VLANs create perimeter security — you secure the boundary between VLANs but traffic within a VLAN is trusted. In modern zero-trust architectures, this is insufficient. Microsegmentation applies firewall policies at the individual workload level, regardless of VLAN.

VMware NSX and Cisco ACI implement microsegmentation using distributed firewalls in the hypervisor's vSwitch. Each VM has its own firewall policy enforced at the virtual NIC level. Two VMs in the same VLAN can be isolated from each other by policy. This is computationally expensive in software but is offloaded to SmartNICs (Data Processing Units — DPUs) in modern deployments.

// CHAPTER 07

VLAN Configuration Reference

Cisco IOS VLAN Configuration

! Create VLANs
vlan 10
 name ENGINEERING
vlan 20
 name SALES
vlan 30
 name SERVERS
vlan 99
 name MANAGEMENT
vlan 999
 name UNUSED_NATIVE

! Access ports
interface range GigabitEthernet0/1-10
 description Engineering-Workstations
 switchport mode access
 switchport access vlan 10
 switchport nonegotiate
 spanning-tree portfast
 spanning-tree bpduguard enable

! Trunk port
interface GigabitEthernet0/24
 description Uplink-to-Distribution
 switchport trunk encapsulation dot1q
 switchport mode trunk
 switchport trunk native vlan 999
 switchport trunk allowed vlan 10,20,30,99
 switchport nonegotiate

! Layer 3 SVIs
ip routing
interface Vlan10
 ip address 10.10.10.1 255.255.255.0
 no shutdown
interface Vlan20
 ip address 10.10.20.1 255.255.255.0
 no shutdown
interface Vlan30
 ip address 10.10.30.1 255.255.255.0
 no shutdown

Verification Commands

# Show VLAN database
show vlan brief

# Show trunk ports and allowed VLANs
show interfaces trunk

# Show a specific interface's VLAN assignment
show interfaces GigabitEthernet0/1 switchport

# Show spanning tree per VLAN
show spanning-tree vlan 10

# Show MAC address table for a VLAN
show mac address-table vlan 10

# Show SVI status
show interfaces vlan 10

Linux (Open vSwitch) VLAN Configuration

# Create OVS bridge
ovs-vsctl add-br br0

# Add access port for VLAN 10
ovs-vsctl add-port br0 eth1 tag=10

# Add trunk port with VLANs 10,20,30
ovs-vsctl add-port br0 eth2 trunks=10,20,30

# Add VXLAN tunnel (VTEP)
ovs-vsctl add-port br0 vxlan0   -- set interface vxlan0 type=vxlan      options:remote_ip=192.168.1.2      options:key=1000

# Linux kernel VLAN (for servers)
ip link add link eth0 name eth0.10 type vlan id 10
ip addr add 10.10.10.100/24 dev eth0.10
ip link set eth0.10 up

// CHAPTER 08

VLANs in Wireless Networks

Wireless networks need VLAN integration too. A corporate campus might have one SSID for employees (mapped to the corporate VLAN), one for guests (mapped to an isolated guest VLAN), and one for IoT devices (mapped to a restricted IoT VLAN) — all broadcasting from the same physical access point.

SSID-to-VLAN Mapping

Modern wireless controllers (Cisco WLC, Aruba, Meraki) map each SSID to a VLAN. The access point's uplink to the switch is a trunk port carrying all VLANs. When a client connects to the guest SSID, the AP tags their traffic with the guest VLAN ID before forwarding it to the switch. The switch treats this traffic identically to any wired VLAN 50 traffic.

# Cisco WLC — WLAN to VLAN mapping
(Cisco Controller) > config wlan interface <wlan-id> <interface-name>

# Example interfaces:
# SSID "CorpNet"   → management interface (VLAN 10)
# SSID "GuestWifi" → dynamic interface (VLAN 100)
# SSID "IoT-Mgmt"  → dynamic interface (VLAN 200)

# Switch AP uplink
interface GigabitEthernet0/20
 description AP-Uplink-Floor-1
 switchport mode trunk
 switchport trunk native vlan 999
 switchport trunk allowed vlan 10,100,200

Guest VLAN Isolation

Guest VLANs require careful design. Guests need internet access but must be isolated from the corporate network. The standard architecture: guest VLAN traffic exits through a dedicated firewall rule that allows only outbound internet traffic (TCP 80, 443, DNS) while blocking all access to RFC 1918 (private) address space. Dynamic captive portal registration can be implemented by intercepting guest HTTP traffic.

Guest VLAN on the same L3 switch as corporate VLANsIf guest and corporate VLANs both have SVIs on the same Layer 3 switch, a misconfigured or missing ACL could allow guests to route to corporate VLANs. Better architecture: route guest VLAN traffic to a dedicated firewall or directly to a separate internet uplink, bypassing the corporate router entirely.

// CHAPTER 09

VLANs and Quality of Service (QoS)

The 3-bit PCP field in the 802.1Q TCI provides Layer 2 QoS marking — called 802.1p. PCP values range from 0 (best effort) to 7 (highest priority). This allows switches to prioritize voice traffic (PCP=5), video traffic (PCP=4), and drop best-effort internet traffic last (PCP=0 or 1) when queues fill under congestion.

CoS-to-DSCP Mapping

PCP (Class of Service, CoS) operates at Layer 2; DSCP (Differentiated Services Code Point) operates at Layer 3 in the IP header. As traffic crosses router boundaries, Layer 2 tags are stripped and only the IP DSCP value persists. QoS policy must map CoS to DSCP at the first L3 hop to ensure consistent treatment across the routed network.

! Cisco IOS — trust CoS marking on ingress
interface GigabitEthernet0/1
 mls qos trust cos

! Map CoS to DSCP globally
mls qos map cos-dscp 0 8 16 24 32 46 48 56

! Apply a QoS policy on voice VLAN
policy-map VOICE-POLICY
 class VOICE-CLASS
  set dscp ef
  priority 1000       ! 1 Gbps guaranteed
 class class-default
  fair-queue

Voice VLANs (Auxiliary VLANs)

IP phones create a special VLAN challenge: the phone is on an access port, but so is the PC connected through the phone's built-in switch. Cisco's auxiliary VLAN (also called voice VLAN) solves this: the port carries two VLANs simultaneously — the data VLAN (untagged, for the PC) and the voice VLAN (tagged with PCP=5, for the phone). The phone learns its VLAN from CDP/LLDP and tags its traffic accordingly.

interface GigabitEthernet0/5
 description IP-Phone-with-PC
 switchport mode access
 switchport access vlan 10           ! PC data traffic — untagged
 switchport voice vlan 40            ! IP phone voice — 802.1Q tagged
 mls qos trust cos                   ! trust CoS marking from phone
 spanning-tree portfast

// CHAPTER 10

Real-World VLAN Design Patterns

// REAL-WORLD SCENARIOA retail chain with 500 stores needs a consistent VLAN design deployed identically at every location. The corporate team defines: VLAN 10 = POS (Point of Sale), VLAN 20 = Employee Wi-Fi, VLAN 30 = Corporate WAN, VLAN 40 = Cameras, VLAN 99 = Management. Each store's switch is auto-provisioned via ZTP (Zero Touch Provisioning) from a central template. Audit compliance checks run nightly via SNMP to confirm VLAN assignments haven't drifted. The standard template is the difference between a manageable 500-store network and chaos.

Enterprise Three-Tier Model

The traditional enterprise campus uses a three-tier hierarchy: Access → Distribution → Core. VLAN assignment happens at the Access layer (end devices). Distribution layer switches (L3) terminate SVIs and route between VLANs. Core switches (L3) carry aggregated traffic between buildings.

VLAN IDs are typically standardized campus-wide. VLAN 10 is always Engineering regardless of which building. This consistency allows network engineers to troubleshoot any switch in the campus using the same mental model. Documentation and monitoring tools that reference VLAN IDs remain valid across refreshes.

VLAN Numbering Standards

There is no enforced VLAN numbering convention, but common schemes include: low numbers (10–99) for user VLANs organized by department, mid-range (100–199) for servers organized by function, high range (200–299) for wireless/IoT, and 800–899 for management. Using multiples of 10 leaves room for future sub-segmentation (VLAN 11 could be "Engineering Guest" without conflict).

VLAN Sprawl and Lifecycle Management

Large networks develop VLAN sprawl — hundreds of VLANs created for projects that have since ended, but nobody deleted them. Abandoned VLANs consume CAM table entries, generate unnecessary STP topology computations, and create security uncertainty ("who knows what's in VLAN 847?"). Best practice: document every VLAN with owner, purpose, and review date. Implement a quarterly VLAN audit that flags VLANs with zero traffic for decommissioning review.

// CHAPTER 11

VLAN Troubleshooting Methodology

The Five Most Common VLAN Issues

1. Native VLAN mismatch. Symptom: inter-switch connectivity works but specific VLANs have traffic issues, or STP errors appear in logs. Diagnosis: show interfaces trunk on both ends of a trunk link and compare native VLAN.

2. Missing VLAN in trunk allowed list. Symptom: hosts in a specific VLAN cannot communicate across switches even though the VLAN exists on both. Diagnosis: show interfaces trunk — the VLAN must appear in "VLANs allowed and active in management domain" column, not just "VLANs allowed on trunk."

3. VLAN exists on access port but not in VLAN database. Symptom: port is assigned VLAN X but traffic doesn't flow. The VLAN must be created in the VLAN database (vlan X) not just referenced on a port. Some platforms auto-create VLANs; others require explicit creation.

4. SVI not up/up. Symptom: hosts have correct IPs and VLAN is configured, but cannot reach their gateway IP. show interfaces vlan 10 shows "down/down." An SVI comes up only when at least one access port in that VLAN is active. No active ports = SVI stays down.

5. Spanning Tree blocking a VLAN. Symptom: intermittent connectivity in a specific VLAN. show spanning-tree vlan X to identify if a port is in BLK state that shouldn't be.

# Comprehensive VLAN troubleshooting workflow
show vlan brief                         # Is the VLAN created and active?
show interfaces GigabitEthernet0/1 swp  # What VLAN is this port in?
show interfaces trunk                   # What VLANs traverse each trunk?
show interfaces vlan 10                 # Is the SVI up?
show spanning-tree vlan 10             # Is STP blocking any ports?
show mac address-table vlan 10         # Are hosts being learned?
show ip arp vlan 10                    # Is L3 resolution working?

// CHAPTER 12

VLANs in the Wild: Case Studies

Healthcare: PCI DSS and HIPAA Segmentation

Healthcare networks must comply with HIPAA (health data) and PCI DSS (payment card data). HIPAA requires that protected health information (PHI) be isolated from non-clinical systems. PCI DSS requires cardholder data environments (CDE) to be network-isolated. A hospital VLAN architecture: VLAN 10 Clinical (EHR, medical devices), VLAN 20 Administrative (email, HR), VLAN 30 Guest/Patient Wi-Fi, VLAN 40 POS/Revenue Cycle, VLAN 50 Medical Imaging (huge file transfers, separate bandwidth), VLAN 99 Management.

Inter-VLAN traffic between Clinical and Administrative must pass through a next-generation firewall with application-layer inspection, not just an L3 switch with ACLs. The firewall policy explicitly permits only necessary clinical application flows and logs all traffic for compliance auditing.

Financial Services: Low-Latency Trading Networks

High-frequency trading (HFT) firms have unusual VLAN requirements: microseconds matter. Standard VLAN processing on managed switches adds ~1–5 µs of latency. HFT networks use specialized low-latency switches (Arista, Cisco Nexus 3000 series) with hardware forwarding pipelines that reduce cut-through latency to sub-microsecond. VLAN tagging still happens in ASICs, but the entire pipeline is optimized.

Market data VLANs carry multicast feeds from exchanges. Trading VLANs carry order flow. Risk management VLANs carry position monitoring. The firm's risk management systems are on a separate VLAN specifically so they can always observe trading VLANs via SPAN (Switched Port Analyzer) monitoring — even if the trading VLAN is congested, the SPAN port to risk management is never dropped.

// CHAPTER 13

Common Misconceptions

✗ Common Mistake — VLANs provide complete security isolationVLANs provide Layer 2 broadcast domain isolation, not security isolation. A misconfigured ACL on the Layer 3 switch allows full inter-VLAN traffic. VLAN hopping attacks bypass VLAN isolation entirely if native VLAN is misconfigured. VLANs are a segmentation tool — they must be combined with ACLs, firewall policies, and proper port configuration to provide actual security. "We have VLANs" is not a complete security answer.
✗ Common Mistake — VLANs and subnets are the same thingVLANs operate at Layer 2 (Ethernet). Subnets operate at Layer 3 (IP). They are correlated but independent. It is technically possible (though inadvisable) to have multiple subnets within one VLAN, or one subnet that spans multiple VLANs (with proxy ARP). In practice, one VLAN maps to one subnet in virtually all enterprise designs. But confusing "I can't reach that IP" with "I'm in the wrong VLAN" without checking both layers leads to circular troubleshooting.
✗ Common Mistake — Trunking a port makes all VLANs accessibleA trunk port carries only VLANs explicitly listed in the trunk's "allowed VLAN" list. By default on Cisco, all VLANs (1–4094) are allowed on a trunk — but best practice is to explicitly restrict this to only VLANs that need to cross the link. An attacker who compromises a trunk port still cannot access VLANs that are pruned from that trunk (they don't carry traffic for those VLANs).
✗ Common Mistake — VLAN 1 is just like any other VLANVLAN 1 is the default VLAN on Cisco equipment and has special behaviors: it is the default native VLAN on trunk ports, it carries CDP/VTP/PAgP/DTP management frames regardless of configuration, and it cannot be deleted. Using VLAN 1 for production traffic is a security risk because management protocol traffic is co-mingled with data. Best practice: move all hosts off VLAN 1, change native VLAN to an unused ID, and treat VLAN 1 as a management-only protocol carrier.
✗ Common Mistake — Layer 3 switches don't need VLANs — just use routingLayer 3 switches still use VLANs internally — the SVIs (Switched Virtual Interfaces) are the Layer 3 representation of VLANs. Saying "use routing instead of VLANs" conflates two different layers. VLANs define which physical ports are in the same broadcast domain. SVIs on an L3 switch provide the gateway IPs that enable routing between those broadcast domains. You need both.
✗ Common Mistake — QinQ is just two VLANs stacked — it's simpleQinQ frames require specific TPID handling. The outer S-Tag uses EtherType 0x88a8 (IEEE 802.1ad) while the inner C-Tag uses 0x8100. Devices that don't understand 0x88a8 will process the frame incorrectly. MTU must also be increased: a standard 1518-byte frame gains 4 bytes for each VLAN tag. With QinQ, you need MTU ≥ 1526 bytes (1500 payload + 14 Ethernet header + 4 C-Tag + 4 S-Tag + 4 FCS). Misconfigured MTU causes intermittent drops on larger packets.

// CHAPTER 14

Interview Questions

Beginner
What is a VLAN and why is it used?
A VLAN (Virtual LAN) is a logical grouping of devices into a broadcast domain, independent of their physical location. VLANs are used to: (1) reduce broadcast traffic by confining broadcasts to a segment, (2) improve security by isolating groups of devices — they cannot directly communicate across VLAN boundaries, (3) simplify network management by grouping devices by function rather than physical location, and (4) allow one physical switch infrastructure to support multiple logically separate networks. The only way to cross a VLAN boundary is through a Layer 3 device (router or L3 switch).
Beginner
Explain the difference between an access port and a trunk port.
An access port belongs to a single VLAN and carries untagged frames — end hosts (PCs, printers, servers) connect to access ports and have no VLAN awareness. The switch adds the VLAN tag internally and strips it before delivery. A trunk port carries multiple VLANs simultaneously using 802.1Q tagging — each frame includes a 12-bit VLAN ID so the receiving switch knows which VLAN it belongs to. Trunk ports are used between switches, to routers, and to hypervisors. The allowed VLAN list on a trunk port controls which VLANs can traverse the link.
Intermediate
What is the 802.1Q tag structure and what does each field do?
The 802.1Q tag is 4 bytes inserted between the Source MAC and EtherType in an Ethernet frame. It consists of: TPID (2 bytes, always 0x8100) — identifies the frame as 802.1Q tagged; TCI (2 bytes) containing: 3-bit PCP (Priority Code Point, 0–7 for 802.1p QoS), 1-bit DEI (Drop Eligible Indicator for congestion), and 12-bit VID (VLAN Identifier, 0–4095). The 12-bit VID supports 4,096 values; 0 and 4095 are reserved, leaving 4,094 usable VLANs. The 4-byte addition increases maximum Ethernet frame size from 1518 to 1522 bytes.
Intermediate
How does VLAN hopping via double-tagging work, and how do you prevent it?
Double-tagging exploits the native VLAN's untagged behavior on trunk ports. An attacker on the native VLAN sends a frame with two 802.1Q tags: outer = native VLAN (stripped by first switch), inner = target VLAN. Switch 1 strips the outer tag (it's native, so forwarded untagged toward Switch 2). Switch 2 sees the inner tag as a legitimate VLAN tag and delivers the frame to the victim VLAN. This is unidirectional — attacker can send but not receive responses. Prevention: change native VLAN to an unused ID (e.g., 999), enable "vlan dot1q tag native" to explicitly tag native VLAN frames, use "switchport mode access" on all end-host ports to disable DTP, and never assign hosts to the native VLAN.
Senior
What is the difference between Router-on-a-Stick and an SVI on a Layer 3 switch for inter-VLAN routing?
Router-on-a-stick uses a router with sub-interfaces on a trunk link to the switch. Each sub-interface encapsulates a different VLAN. All inter-VLAN traffic must traverse the single physical uplink to the router and back — creating a bandwidth bottleneck. Routing is done in software (or NPU), typically adding ~50µs latency. Layer 3 switch SVIs (Switched Virtual Interfaces) create virtual gateway interfaces directly in the switch. Routing between SVIs uses hardware ASICs (TCAM-based FIB lookup), adding ~1–3µs latency. A modern L3 switch can route 200M+ pps between SVIs simultaneously without any uplink bottleneck. SVIs also eliminate the need for a separate router device, reducing cost and failure domains. Use RoaS in small environments where an L3 switch is unavailable; use SVIs in any production environment.
PhD
Explain how BGP EVPN eliminates ARP flooding in VXLAN fabrics and its implications for VLAN-scale design.
Traditional VLANs use flood-and-learn for MAC discovery and broadcast ARP for IP-to-MAC resolution. In a VXLAN fabric, flooding would require every VTEP to replicate traffic to all other VTEPs in the same VNI — O(n) traffic for n VTEPs, catastrophically unscalable. BGP EVPN (RFC 7432) replaces flooding with a distributed control plane. When a host comes online, its local VTEP advertises a Type-2 (MAC/IP Advertisement) route via MP-BGP UPDATE, carrying the host's MAC and IP bound to the local VTEP's IP. All remote VTEPs install this as a host route and ARP proxy entry. When any host needs to ARP, the local VTEP answers from its local cache — the ARP request never traverses the fabric. This reduces fabric ARP traffic from O(n×m) (n hosts × m VTEPs) to O(1) — a single BGP advertisement. EVPN also provides: Type-3 routes for BUM (Broadcast, Unknown, Multicast) traffic optimization via ingress replication lists; Type-5 routes for IP prefix advertisement enabling VXLAN-to-IP-VRF routing without flood; consistent policy anchor points for microsegmentation. The architectural implication: VXLAN+EVPN scales to millions of virtual segments because the control plane complexity is O(n log n) BGP routes rather than O(n²) flooded traffic.
PhD
In a multi-tenant cloud environment, how would you design VLAN/overlay segmentation to satisfy 10,000 tenants with strict isolation guarantees?
Classic 802.1Q VLANs are insufficient — 4,094 usable IDs is far below 10,000. The architecture requires an overlay model: VXLAN provides 16.7M VNIs (24-bit identifier), eliminating the ID constraint. Each tenant receives one or more VNIs mapped to their VPC/VNet. Control plane: BGP EVPN distributes MAC/IP/prefix bindings across all VTEPs; each tenant's routes live in a dedicated VRF (Virtual Routing and Forwarding instance), providing routing isolation at the IP layer. Data plane: VTEP encapsulation ensures tenant traffic never appears in another tenant's L2 domain; outer IP/UDP headers carry tenant traffic transparently across the physical fabric. Security: VRF isolation prevents inter-tenant routing (packets destined to another VRF are dropped by the routing policy, not by VLAN membership); additionally, security groups implemented in the hypervisor's vSwitch or hardware DPU enforce per-flow policies. Verification: each tenant's VNI/VRF has an independent routing table, ARP cache, and MAC table — a compromised tenant VM cannot see or affect another tenant's routing entries. Scalability: with BGP EVPN, adding a new tenant requires only provisioning a new VNI, a new VRF, and advertising the first host route — the control plane converges incrementally without impacting existing tenants.

🎯 Key Takeaways

  • VLANs create logical broadcast domains on shared switch infrastructure — one physical switch can host dozens of isolated VLANs simultaneously.
  • 802.1Q inserts a 4-byte tag (TPID + TCI) into Ethernet frames; the 12-bit VID supports 4,094 usable VLAN IDs (0 and 4095 reserved).
  • Access ports carry untagged traffic for one VLAN; trunk ports carry tagged traffic for multiple VLANs using 802.1Q.
  • The native VLAN is sent untagged on trunk ports — mismatched native VLANs between switches cause traffic misassignment and STP issues.
  • Inter-VLAN routing requires a Layer 3 device; Layer 3 switch SVIs route between VLANs in hardware ASICs at line rate (~1–3 µs).
  • VLAN hopping via double-tagging exploits the native VLAN — mitigate by assigning an unused VLAN ID as native and tagging it explicitly.
  • DTP auto-trunking is a security risk; configure all end-host ports explicitly with switchport mode access and switchport nonegotiate.
  • VTP Server mode can wipe an entire campus VLAN database if a higher-revision switch is plugged in — prefer VTP Transparent or VTP v3.
  • VXLAN extends VLAN concepts to 16 million virtual segments (24-bit VNI), enabling cloud-scale multi-tenant network isolation.
  • BGP EVPN eliminates ARP flooding in VXLAN fabrics by distributing MAC/IP bindings via BGP — converting O(n²) floods to O(n log n) control-plane updates.
Share

Discussion

0

Have a better approach? Found something outdated? Share it — your knowledge helps everyone learning here.

Continue with GitHub
Loading...