Lesson 5 of 10
Network Segmentation & VLAN Security
Network segmentation divides a network into isolated zones to limit lateral movement after a breach. VLANs (Virtual LANs) are the primary mechanism for implementing segmentation at the data link layer.
Why Network Segmentation Matters
# Without segmentation: Flat network - breach of one = breach of all
Flat Network Risk:
All devices: servers, workstations, printers, IP cameras, IoT = one network
Attack: Phishing email compromises sales laptop
→ Lateral movement: scan 192.168.1.0/24 (all 254 hosts accessible)
→ Find: database at 192.168.1.50, HR server at 192.168.1.75, AD at 192.168.1.10
→ Compromise AD → domain admin → total network control
With Segmentation:
VLAN 10: Servers 10.0.10.0/24 (API servers, app servers)
VLAN 20: Databases 10.0.20.0/24 (PostgreSQL, Redis, MySQL)
VLAN 30: Workstations 10.0.30.0/24 (Employee laptops)
VLAN 40: Management 10.0.40.0/24 (Servers, network devices admin)
VLAN 50: IoT 10.0.50.0/24 (Printers, cameras, smart devices)
VLAN 60: Guest WiFi 10.0.60.0/24 (Internet only - no internal access)
Attack: Same phishing → sales laptop compromised (VLAN 30)
→ Can ONLY reach other VLAN 30 devices (other workstations)
→ Firewall BLOCKS cross-VLAN traffic except approved paths
→ Cannot reach databases (VLAN 20) or management (VLAN 40)
→ Blast radius dramatically reducedVLAN Hopping Attacks
# VLAN Hopping: Bypassing VLAN segmentation
# Attack 1: Switch Spoofing
# Many switches auto-negotiate trunk links (DTP - Dynamic Trunking Protocol)
# Attacker configures their NIC to act as a trunk - receives traffic from all VLANs
#
# Defense: Disable DTP on all access ports:
# Switch(config-if)# switchport mode access
# Switch(config-if)# switchport nonegotiate
# Switch(config-if)# switchport access vlan 30
# Attack 2: Double Tagging
# Exploit: 802.1Q VLAN tags are sometimes processed twice
# Attacker (VLAN 30) sends frame with TWO tags: outer=30, inner=20
# First switch strips outer tag (30) - forwards to trunk with inner tag (20)
# Second switch sees inner tag (20) - delivers to VLAN 20 (Database VLAN!)
#
# Defense:
# Set native VLAN to an unused VLAN ID (not VLAN 1):
# Switch(config-if)# switchport trunk native vlan 999 (unused VLAN)
# Tag native VLAN traffic explicitly:
# Switch(config)# vlan dot1q tag native
# Best practices for VLAN security:
# 1. Disable unused switch ports and assign to dead VLAN
# 2. Change default VLAN 1 (never use VLAN 1 for production)
# 3. Disable automatic trunk negotiation (DTP)
# 4. Use 802.1X port authentication - authenticate devices before granting VLAN accessCommon Mistakes
- Using VLAN 1 as a production VLAN - VLAN 1 is the default on all switches and cannot be disabled on trunks; use custom VLAN IDs for all production traffic
- VLANs without inter-VLAN firewall rules - VLANs only provide Layer 2 separation; without firewall rules controlling inter-VLAN traffic, a Layer 3 route allows complete access between segments
- Putting security cameras and production servers on the same VLAN - IP cameras are notoriously unpatched; isolate IoT and OT (operational technology) devices in their own segment
Tip
Tip
Practice Network Segmentation VLAN Security in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).
Practice Task
Note
Practice Task - (1) Write a working example of Network Segmentation VLAN Security from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Network Segmentation VLAN Security is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.
Key Takeaways
- Network segmentation divides a network into isolated zones to limit lateral movement after a breach.
- Using VLAN 1 as a production VLAN - VLAN 1 is the default on all switches and cannot be disabled on trunks; use custom VLAN IDs for all production traffic
- VLANs without inter-VLAN firewall rules - VLANs only provide Layer 2 separation; without firewall rules controlling inter-VLAN traffic, a Layer 3 route allows complete access between segments
- Putting security cameras and production servers on the same VLAN - IP cameras are notoriously unpatched; isolate IoT and OT (operational technology) devices in their own segment
Finished this lesson?