Domain 2Network AccessCORE

VLANs and Inter-VLAN Routing

Creating and managing VLANs, configuring 802.1Q trunking, and implementing inter-VLAN routing using Router-on-a-Stick and Layer 3 switches.

Domain: Domain 2: Network Access•Updated: 2026-08-26
#VLAN#Trunking#Inter-VLAN Routing#Router on a Stick#Layer 3 Switch

VLANs, Trunking, and Inter-VLAN Routing (CCNA 200-301)

LANs and Broadcast Domains

  • Concept: A LAN (Local Area Network) is defined as a single Broadcast Domain.
  • Broadcast Domain: The group of devices that will receive a broadcast frame (Destination MAC FFFF.FFFF.FFFF) sent by any member within that group.
  • Device Behavior:
    • Switches: Flood broadcast and unknown unicast frames out all interfaces except the receiving interface. They do NOT break broadcast domains.
    • Routers: Do NOT forward broadcast frames. They break broadcast domains. Every router interface represents a separate broadcast domain.

VLAN Basics and Purpose

  • Concept: A VLAN (Virtual Local Area Network) logically separates a single Layer 2 broadcast domain into multiple distinct broadcast domains on the same physical switch.
  • Purpose:
    • Security: Limits Layer 2 reachability. Forces inter-departmental traffic to pass through a Layer 3 router/firewall where Access Control Lists (ACLs) can be applied.
    • Performance: Reduces unnecessary broadcast and unknown unicast traffic, preventing network congestion.
  • VLAN Ranges:
    • Normal Range: 1 - 1005
    • Extended Range: 1006 - 4094
    • Total Usable: 1 - 4094 (VLAN 0 and 4095 are reserved).
  • Default VLANs:
    • VLAN 1: Default VLAN for all ports. Cannot be deleted.
    • VLANs 1002-1005: Pre-allocated for legacy FDDI and Token Ring. Cannot be deleted.

Switch Port Types: Access vs. Trunk

  • Access Port: Belongs to a single VLAN. Connects to end hosts (PCs, servers, printers). Frames are untagged.
  • Trunk Port: Carries traffic for multiple VLANs between switches, or between a switch and a router. Frames are tagged (except for the Native VLAN).
Feature Access Port Trunk Port
VLAN Membership Single VLAN Multiple VLANs
Typical Connection End Hosts (PC, AP) Switch-to-Switch, Switch-to-Router
Frame Tagging Untagged Tagged (802.1Q)
Alternative Name Untagged Port Tagged Port

802.1Q Encapsulation (Dot1q)

  • Concept: The IEEE industry-standard protocol for VLAN tagging over trunk links. (Note: ISL is an old Cisco-proprietary alternative, rarely used and unsupported on modern gear).
  • Details: The 802.1Q tag is 4 bytes (32 bits) long and is inserted between the Source MAC and Type/Length fields of the original Ethernet frame.
  • Tag Fields:
Field Size Description
TPID (Tag Protocol Identifier) 16 bits (2 bytes) Always set to hexadecimal 0x8100. Identifies the frame as 802.1Q tagged.
TCI (Tag Control Information) 16 bits (2 bytes) Contains three sub-fields: PCP, DEI, and VID.
↳ PCP (Priority Code Point) 3 bits Used for Class of Service (CoS) to prioritize traffic.
↳ DEI (Drop Eligible Indicator) 1 bit Indicates if the frame can be dropped during congestion.
↳ VID (VLAN ID) 12 bits Identifies the specific VLAN (1-4094).

Native VLAN

  • Concept: A specific VLAN configured on a trunk port whose traffic is sent untagged.
  • Details:
    • Default Native VLAN is VLAN 1.
    • When a switch receives an untagged frame on a trunk, it assumes the frame belongs to the Native VLAN.
    • Mismatch: If Native VLANs do not match on both sides of a trunk, traffic will be placed in the wrong VLAN, causing security and connectivity issues. CDP/DTP will generate a Native VLAN mismatch error.
    • Best Practice: Change the Native VLAN to an unused, dedicated “dummy” VLAN for security purposes.

Inter-VLAN Routing (IVR) Methods

  • Concept: Because switches do not route between VLANs, a Layer 3 device is required to route traffic between them.
Method Description Pros Cons
Legacy (Multiple Interfaces) One physical router interface per VLAN. Simple to configure. Wastes router interfaces; not scalable.
ROAS (Router on a Stick) Single physical router interface divided into logical subinterfaces. Saves physical interfaces. Can become a bottleneck (1Gbps link shared by all VLANs).
Layer 3 Switching Uses a Multilayer Switch with SVIs to route internally. Extremely fast (hardware-based routing); highly scalable. Requires more expensive Layer 3 switches.
flowchart TD
    subgraph ROAS Path
    PC1[PC VLAN 20] -->|Untagged| SW1[Switch]
    SW1 -->|Tagged VLAN 20| R1[Router Subinterface .20]
    R1 -->|Routes to VLAN 10| R1_2[Router Subinterface .10]
    R1_2 -->|Tagged VLAN 10| SW1
    SW1 -->|Untagged| PC2[PC VLAN 10]
    end

    subgraph Layer 3 Switch Path
    PC3[PC VLAN 20] -->|Untagged| L3SW[Layer 3 Switch]
    L3SW -->|Routes internally via SVI| L3SW2[SVI VLAN 10]
    L3SW2 -->|Tagged VLAN 10| SW2[Access Switch]
    SW2 -->|Untagged| PC4[PC VLAN 10]
    end

Router on a Stick (ROAS) Configuration

  • Concept: Uses logical subinterfaces on a single physical router interface to route between VLANs. The physical interface has no IP address; IPs are assigned to subinterfaces.
  • Details: Subinterface numbers (e.g., g0/0.10) do not have to match the VLAN ID, but it is highly recommended for clarity.
  • Native VLAN on Router:
    • Option 1: Use encapsulation dot1q [vlan] native on a subinterface.
    • Option 2: Assign the Native VLAN’s IP address directly to the physical router interface (no subinterface needed for that VLAN).

Layer 3 Switching & SVIs

  • Concept: A Multilayer Switch (Layer 3 Switch) can perform both Layer 2 switching and Layer 3 routing.
  • SVI (Switch Virtual Interface): A virtual interface representing a VLAN. Used as the default gateway for hosts in that VLAN.
  • Routed Port: A physical switchport configured to act like a router interface (Layer 3 only, no VLANs).
  • SVI Up/Up Conditions: An SVI will remain down/down unless ALL of the following are true:
    1. The VLAN exists on the switch (SVIs do not auto-create VLANs, unlike access ports).
    2. The SVI is enabled (no shutdown).
    3. The VLAN itself is not shutdown (shutdown under vlan [id] config).
    4. At least one access port in the VLAN is up/up, OR at least one trunk port allowing the VLAN is up/up.

Basic VLAN & Access Port Configuration

  • Concept: Creating VLANs, naming them, and assigning access ports.
  • Details: Assigning an access port to a non-existent VLAN will automatically create the VLAN.
! Check existing VLANs
Switch# show vlan brief

! Create and name a VLAN manually
Switch(config)# vlan 10
Switch(config-vlan)# name ENGINEERING
Switch(config-vlan)# exit

! Configure an interface as an Access Port
Switch(config)# interface range g1/0 - 3
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 10
! Note: If VLAN 10 didn't exist, it is auto-created here.

Things to note: show vlan brief only displays access ports assigned to VLANs. It will NOT show trunk ports.

Trunk Port Configuration

  • Concept: Configuring an interface to carry multiple VLANs, setting encapsulation, restricting allowed VLANs, and changing the Native VLAN.
  • Details: By default, ALL VLANs (1-4094) are allowed on a trunk. For security and performance, prune unnecessary VLANs.
! Set encapsulation (Only required on older switches supporting both ISL and Dot1q)
Switch(config-if)# switchport trunk encapsulation dot1q

! Manually force the port into Trunk mode
Switch(config-if)# switchport mode trunk

! Restrict allowed VLANs on the trunk
Switch(config-if)# switchport trunk allowed vlan 10,30
Switch(config-if)# switchport trunk allowed vlan add 20
Switch(config-if)# switchport trunk allowed vlan remove 20
Switch(config-if)# switchport trunk allowed vlan all
Switch(config-if)# switchport trunk allowed vlan except 1-5,10
Switch(config-if)# switchport trunk allowed vlan none

! Change the Native VLAN (Best Practice: use an unused VLAN)
Switch(config-if)# switchport trunk native vlan 1001

! Verify trunk configuration
Switch# show interfaces trunk

Things to note: In show interfaces trunk, the section “Vlans allowed and active in management domain” will only list VLANs that actually exist on the switch. If you allow VLAN 50 on a trunk but haven’t created VLAN 50 locally, it won’t appear in this specific list.

Router on a Stick (ROAS) Configuration

  • Concept: Configuring subinterfaces on a router for Inter-VLAN Routing.
! Enable the physical interface (No IP address on physical interface)
Router(config)# interface g0/0
Router(config-if)# no shutdown
Router(config-if)# exit

! Configure Subinterface for VLAN 10
Router(config)# interface g0/0.10
Router(config-subif)# encapsulation dot1q 10
Router(config-subif)# ip address 192.168.1.254 255.255.255.192

! Configure Subinterface for VLAN 20
Router(config)# interface g0/0.20
Router(config-subif)# encapsulation dot1q 20
Router(config-subif)# ip address 192.168.1.126 255.255.255.192

! Configure Native VLAN on a subinterface (Option 1)
Router(config)# interface g0/0.1
Router(config-subif)# encapsulation dot1q 1 native
Router(config-subif)# ip address 192.168.1.62 255.255.255.192

Layer 3 Switch Configuration

  • Concept: Enabling routing on a switch, creating SVIs for VLANs, and configuring physical routed ports.
! Enable Layer 3 routing globally on the switch (CRITICAL STEP)
Switch(config)# ip routing

! Configure an SVI (Switch Virtual Interface) for VLAN 10
Switch(config)# interface vlan 10
Switch(config-if)# ip address 192.168.1.254 255.255.255.192
Switch(config-if)# no shutdown
! Note: SVIs are shutdown by default!

! Convert a physical switchport into a Layer 3 Routed Port
Switch(config)# interface g0/1
Switch(config-if)# no switchport
Switch(config-if)# ip address 192.168.1.193 255.255.255.252
Switch(config-if)# no shutdown

! Configure a default route on the Layer 3 Switch pointing to an upstream router
Switch(config)# ip route 0.0.0.0 0.0.0.0 192.168.1.194

! Verify SVI and Routing status
Switch# show ip interface brief
Switch# show ip route
Switch# show interfaces status

Things to note: The no switchport command changes the port type from Layer 2 to Layer 3. In show interfaces status, a routed port will display routed in the VLAN column instead of a VLAN number.

Complete Command Reference

Verification Commands

Switch# show vlan brief
Switch# show interfaces trunk
Switch# show ip interface brief
Switch# show ip route
Switch# show interfaces status

Access Port & VLAN Commands

Switch(config)# vlan [1-4094]
Switch(config-vlan)# name [NAME]
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan [1-4094]

Trunk Port Commands

Switch(config-if)# switchport trunk encapsulation dot1q
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk allowed vlan [vlan-list]
Switch(config-if)# switchport trunk allowed vlan add [vlan-list]
Switch(config-if)# switchport trunk allowed vlan remove [vlan-list]
Switch(config-if)# switchport trunk allowed vlan all
Switch(config-if)# switchport trunk allowed vlan except [vlan-list]
Switch(config-if)# switchport trunk allowed vlan none
Switch(config-if)# switchport trunk native vlan [1-4094]

Router on a Stick (ROAS) Commands

Router(config)# interface [interface-id].[subinterface-id]
Router(config-subif)# encapsulation dot1q [vlan-id]
Router(config-subif)# encapsulation dot1q [vlan-id] native
Router(config-subif)# ip address [ip] [mask]

Layer 3 Switch Commands

Switch(config)# ip routing
Switch(config)# interface vlan [vlan-id]
Switch(config-if)# ip address [ip] [mask]
Switch(config-if)# no shutdown
Switch(config-if)# no switchport
Switch(config)# ip route 0.0.0.0 0.0.0.0 [next-hop-ip]