Segmentation: Zones, VLANs, and Lateral Movement
The Problem: Flat Networks Let Attacks Roam Freely
In a flat network, every host can reach every other host. If an attacker compromises a single workstation — through phishing, a vulnerable web application, or a stolen credential — they can scan and attack every other system on the network. There are no barriers to lateral movement. The attacker can reach file servers, databases, domain controllers, and other high-value targets from the initial foothold.
Network segmentation addresses this by dividing the network into isolated zones with controlled traffic flows between them. Each zone has a defined trust level, and traffic between zones is filtered by firewall rules. A compromise in one zone does not automatically grant access to adjacent zones.
The Trust Zone Model
Segmentation starts with classifying assets by trust level and function:
- External/Untrusted — the internet, partner networks, guest Wi-Fi
- DMZ (Semi-Trusted) — internet-facing services: web servers, reverse proxies, mail gateways
- Internal/Trusted — corporate workstations, internal applications, management interfaces
- Restricted/High-Value — databases, domain controllers, financial systems, PII stores
- Management — jump hosts, SIEM, logging infrastructure, backup systems
The principle: traffic flows from lower-trust to higher-trust zones only through explicitly allowed paths. A workstation in the internal zone should never need to connect directly to a database in the restricted zone — the application server in the DMZ or internal zone mediates that access.
VLANs and Subnet Segmentation
VLANs (Virtual Local Area Networks) are the most common segmentation mechanism at Layer 2. Each VLAN is a separate broadcast domain. Hosts in VLAN 10 cannot communicate with hosts in VLAN 20 without a router or Layer 3 switch to forward traffic between them. This is where firewall rules are applied — at the inter-VLAN routing point.
VLAN 10 (Workstations) ──┐
├──[ Firewall / L3 Switch ]── Internet
VLAN 20 (DMZ) ──┤
│
VLAN 30 (Database) ──┘
Subnet segmentation complements VLANs at Layer 3. Each zone gets its own IP subnet, and routing between subnets is controlled by Access Control Lists (ACLs) on the router or firewall. This provides defense-in-depth: even if VLAN hopping succeeds (through double-tagging or switch spoofing), the Layer 3 ACLs still restrict traffic.
Microsegmentation
Traditional segmentation is coarse — entire subnets are trusted or untrusted. Microsegmentation applies firewall rules at the individual workload level, even within the same subnet. This is achieved through:
- Host-based firewalls — Windows Defender Firewall, iptables, or nftables on each host
- Software-defined networking (SDN) — VMware NSX, Cisco ACI, or cloud security groups that enforce per-workload policies
- Container network policies — Kubernetes NetworkPolicies that restrict pod-to-pod traffic
Microsegmentation is essential in cloud and containerized environments where workloads in the same subnet may have different trust levels. A compromised web server in a Kubernetes cluster should not be able to reach the database pod unless a NetworkPolicy explicitly allows it.
# Kubernetes NetworkPolicy: only allow traffic from the api pods to the database
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: db-allow-from-api
spec:
podSelector:
matchLabels:
app: database
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
app: api
ports:
- protocol: TCP
port: 5432
Lateral Movement Confinement
The primary security benefit of segmentation is confining lateral movement. When an attacker compromises a host, their ability to reach high-value targets is limited by the segmentation rules:
- A compromised workstation in VLAN 10 can reach the DMZ (VLAN 20) but not the database (VLAN 30)
- A compromised web server in the DMZ can reach the application server but not the domain controller
- A compromised container in the frontend namespace cannot reach the backend database namespace
Each barrier forces the attacker to find and exploit another vulnerability, increasing the time and effort required and giving defenders more opportunities to detect the intrusion.
Firewall Architecture: Rules, Types, and Placement
Deny by Default: The Firewall Mindset
A firewall is a traffic filter. It examines packets or connections and decides whether to allow or block them based on a rule set. The single most important principle in firewall configuration is deny by default — if a rule does not explicitly allow traffic, it is blocked. This is the opposite of the legacy approach (allow by default, block known-bad) which leaves enormous gaps for unknown threats.
Firewall Types
Packet-Filtering Firewalls (Layer 3/4)
The simplest firewall type. Examines each packet's source/destination IP, protocol, and port. Makes allow/deny decisions based on these header fields alone. Fast but cannot inspect payload content or track connection state.
# Example packet-filter rule (iptables)
# Allow inbound HTTP from anywhere
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# Allow outbound DNS
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
# Drop everything else
iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP
Stateful Firewalls (Layer 4 with state tracking)
Track the state of active connections. When an internal host initiates a connection to an external server, the firewall automatically allows the return traffic without an explicit rule. This is more secure than packet filtering because it distinguishes between new connections (which require explicit rules) and established connections (which are part of an existing flow).
Next-Generation Firewalls (NGFW, Layer 7)
Combine stateful inspection with application-layer awareness, intrusion prevention, and identity-based policies. An NGFW can distinguish between HTTP traffic to a legitimate web application and HTTP traffic carrying SQL injection payloads. It can enforce policies like "allow Facebook but block Facebook chat" or "allow Windows Update but block other outbound HTTP."
Web Application Firewalls (WAF)
Specialized for HTTP/HTTPS traffic. Inspects request and response payloads for SQL injection, cross-site scripting, and other application-layer attacks. Deployed in front of web applications as a reverse proxy.
Rule Design Principles
- Deny by default — the last rule in any rule set should be an explicit deny-all
- Least privilege — allow only the specific traffic required for business function, nothing more
- Documented justification — every allow rule should have a comment explaining the business need
- Specific over general —
allow tcp 10.0.1.0/24 to 10.0.2.10 port 443is better thanallow tcp any to any - Regular review — stale rules accumulate and create unnecessary attack surface
# Well-documented firewall rule example
# Rule: Allow web tier to reach app tier on the API port
# Business need: Web servers call the REST API on app servers
# Owner: Platform team, reviewed 2026-01-15
allow tcp 10.0.2.0/24 10.0.3.0/24 8443
# Rule: Allow monitoring to scrape metrics from all app servers
# Business need: Prometheus scrapes /metrics endpoint
# Owner: SRE team, reviewed 2026-01-15
allow tcp 10.0.4.10/32 10.0.3.0/24 9090
Firewall Placement
Perimeter Firewall
Sits at the network boundary between the internal network and the internet. Controls all inbound and outbound traffic. This is the traditional firewall placement and remains essential, but it is not sufficient on its own — once an attacker bypasses the perimeter (through phishing, a compromised VPN, or a vulnerable web application), there are no internal barriers.
Internal Firewall
Segments internal zones from each other. Enforces the trust zone model — workstations cannot reach databases, DMZ servers cannot reach management interfaces. Internal firewalls are the technical control that makes segmentation enforceable.
Host-Based Firewall
Runs on each endpoint (Windows Defender Firewall, iptables, nftables). Provides the last line of defense when network-level segmentation fails. In a zero-trust architecture, host-based firewalls enforce per-workload policies that do not depend on network location.
# Host-based firewall: allow only SSH from the management subnet
iptables -A INPUT -p tcp -s 10.0.4.0/24 --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j DROP
DMZ Architecture
The Demilitarized Zone (DMZ) is a network segment that hosts internet-facing services. It is called a DMZ because it is neither fully trusted (like the internal network) nor fully untrusted (like the internet) — it is a buffer zone.
Internet ──[ Perimeter FW ]── DMZ (Web servers, reverse proxy)
│
[ Internal FW ]── Internal network (workstations, databases)
Traffic flow rules for a DMZ:
- Internet → DMZ: allowed only on specific ports (80, 443) to specific servers
- DMZ → Internet: allowed for software updates and external API calls, but restricted
- DMZ → Internal: denied by default; only specific application-to-database flows are allowed
- Internal → DMZ: allowed for management and monitoring
- Internal → Internet: allowed through the perimeter firewall with content filtering
The key principle: a compromised DMZ server must not provide a foothold into the internal network. The internal firewall enforces this by blocking all unsolicited traffic from the DMZ to internal zones.
Zero Trust and Modern Segmentation
Beyond Perimeter: Zero Trust Architecture
Traditional network security assumed that everything inside the perimeter was trusted. Zero trust rejects that assumption. The core principle: never trust, always verify. Every request — whether it originates from inside or outside the network — must be authenticated, authorized, and encrypted before access is granted.
Zero Trust Principles
- Verify explicitly — authenticate and authorize every request based on all available data points: user identity, device health, location, data classification, and service sensitivity
- Least privilege access — grant only the minimum permissions needed for the specific task, for the shortest time necessary (just-in-time access)
- Assume breach — design the network as if the attacker is already inside. Segment aggressively, monitor everything, and minimize blast radius
Identity-Aware Proxies
In a zero-trust architecture, access to applications is mediated by an identity-aware proxy rather than by network location. The user authenticates to the proxy (using SSO, MFA, and device posture checks), and the proxy forwards the request to the backend service only if the authorization policy allows it.
User → [ Identity-Aware Proxy ] → Backend Service
↑ ↑
Authenticates user Service-to-service
Checks device health authentication (mTLS)
Evaluates policy Authorization
This means that network segmentation alone is not sufficient — the application must also verify identity and enforce authorization. A compromised workstation on the internal network cannot access the database even if the firewall rules allow it, because the identity-aware proxy rejects the request (the workstation does not have valid user credentials for that service).
Software-Defined Perimeters
A software-defined perimeter (SDP) hides infrastructure from unauthorized users. The infrastructure is dark — it does not respond to port scans, DNS queries, or any traffic from unauthenticated sources. Only after successful authentication does the SDP controller instruct the firewall to allow traffic from that specific user to that specific service.
Unauthenticated user → Port scan → No response (infrastructure is dark)
Authenticated user → SDP controller → Firewall opens pinhole → Access granted
Practical Implementation
Zero trust is a journey, not a product. A practical implementation path:
- Inventory and classify — identify all assets, data flows, and trust relationships
- Segment the network — implement VLANs, subnets, and firewall rules based on the trust zone model
- Deploy identity-aware access — implement SSO, MFA, and conditional access policies
- Encrypt everything — TLS for all traffic, mTLS for service-to-service communication
- Monitor and log — collect all access logs, analyze for anomalies, and alert on policy violations
- Automate response — integrate with SOAR to automatically isolate compromised hosts or revoke access
Cloud Segmentation
In cloud environments, segmentation is implemented through security groups, network ACLs, and virtual private clouds (VPCs). Each VPC is an isolated network with its own routing tables and security groups. VPC peering and transit gateways control traffic between VPCs.
# AWS Security Group: allow only the web tier to reach the database
resource "aws_security_group" "db" {
name = "database-sg"
ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
security_groups = [aws_security_group.web.id]
}
}
Cloud-native segmentation is more flexible than physical segmentation because policies are defined in code, can be version-controlled, and can be automatically validated against security baselines.
Practice Problems
Solution
Problems: (1) Rule 1 is overly permissive — it allows all traffic from the entire 10.0.0.0/8 range to anywhere, which negates the deny rule 2 (since rule 1 matches first). (2) Rule 2 is ineffective because it comes after rule 1 — firewall rules are processed top-down, and rule 1 already allows the traffic that rule 2 tries to deny. (3) Rule 3 allows all HTTPS traffic from anywhere to anywhere, which is unnecessary and creates attack surface. Corrections: (1) Replace rule 1 with specific allow rules for required traffic only. (2) Move rule 2 above any general allow rules, or restructure so deny rules take precedence. (3) Replace rule 3 with specific rules allowing HTTPS only from known sources to specific destinations. (4) Add an explicit deny-all rule at the end. (5) Add comments documenting the business justification for each allow rule. Solution
Zones: (1) Internet (untrusted), (2) DMZ — web servers and reverse proxy, (3) Internal — workstations and internal apps, (4) Restricted — database servers. Traffic flows: Internet → DMZ: allow TCP 80/443 to DMZ web servers only. DMZ → Internet: allow TCP 443 for software updates and external API calls, restricted by destination. DMZ → Internal: deny all by default; allow only the specific database port (e.g., TCP 5432) from DMZ web servers to database servers. Internal → DMZ: allow TCP 22 from management jump hosts to DMZ servers for administration. Internal → Internet: allow TCP 80/443 through perimeter firewall with content filtering. Firewall rules: Perimeter firewall handles Internet↔DMZ and Internet↔Internal. Internal firewall handles DMZ↔Internal and Internal↔Restricted. All rules are deny-by-default with explicit allows for documented business needs. Quiz
1. What is the primary security benefit of network segmentation?
2. Why is deny-by-default the correct firewall rule design principle?
3. What is the purpose of a DMZ in network architecture?
4. What is microsegmentation and when is it most important?
5. In a zero-trust architecture, what replaces network location as the primary access control mechanism?
Flashcards
Question
What is network segmentation?
Click to reveal answer
Answer
Dividing a network into isolated zones with different trust levels, where traffic between zones is filtered by firewall rules. Confines lateral movement when a host is compromised.
Question
What is the deny-by-default principle?
Click to reveal answer
Answer
A firewall design principle where any traffic not explicitly allowed is blocked. Minimizes attack surface by ensuring only documented, business-required traffic is permitted.
Question
What is a DMZ?
Click to reveal answer
Answer
A semi-trusted network segment hosting internet-facing services. Acts as a buffer between the untrusted internet and the trusted internal network. A compromised DMZ server cannot reach internal systems.
Question
What is microsegmentation?
Click to reveal answer
Answer
Applying firewall rules at the individual workload level (host firewalls, SDN, container policies) rather than at the subnet level. Essential in cloud and container environments.
Question
What is the core principle of zero trust?
Click to reveal answer
Answer
Never trust, always verify. Every request must be authenticated, authorized, and encrypted regardless of whether it originates from inside or outside the network. Network location does not imply trust.
Question
What is the difference between a stateful firewall and a packet-filtering firewall?
Click to reveal answer
Answer
A packet-filtering firewall examines each packet's header (IP, port, protocol) in isolation. A stateful firewall tracks the state of active connections and automatically allows return traffic for established connections, providing better security with fewer rules.
Revision Notes
Key Takeaways
- 1. Segmentation confines lateral movement by restricting traffic between zones of different trust levels
- 2. Deny-by-default is the fundamental firewall principle — only explicitly allowed traffic is permitted
- 3. DMZ isolates internet-facing services from internal networks, creating a buffer zone
- 4. Microsegmentation enforces per-workload policies, essential in cloud and container environments
- 5. Zero trust replaces network location with identity-based authentication and authorization
- 6. Defense in depth requires perimeter, internal, and host-based firewalls working together
Interview Tips
- • Explain the trust zone model with a concrete example: how a compromised workstation cannot reach the database
- • Discuss why deny-by-default matters — the risk of stale rules and unknown services in allow-by-default configurations
- • Describe DMZ traffic flows: Internet→DMZ, DMZ→Internal, and why each is restricted differently
- • Explain microsegmentation in the context of Kubernetes NetworkPolicies or cloud security groups
- • Discuss zero trust as a journey — inventory, segment, identity-aware access, encrypt, monitor
- • Mention how segmentation and firewalls work together — segmentation defines the zones, firewalls enforce the rules
Cheat Sheet
Network Segmentation and Firewall Architecture Cheat Sheet
Phase: Network Attacks and Defense | Level: intermediate
Segmentation concepts:
- Trust zones: External → DMZ → Internal → Restricted → Management
- VLANs: Layer 2 segmentation, separate broadcast domains
- Subnets: Layer 3 segmentation, ACLs at routing points
- Microsegmentation: per-workload firewall rules (host FW, SDN, K8s policies)
Firewall types:
- Packet-filtering (L3/4): header-based, fast, no state tracking
- Stateful (L4): tracks connection state, allows return traffic automatically
- NGFW (L7): application awareness, IPS, identity-based policies
- WAF: HTTP/HTTPS payload inspection for SQLi, XSS
Rule design:
- Deny by default — last rule is explicit deny-all
- Least privilege — only what business requires
- Documented justification — comment every allow rule
- Specific over general — avoid 'allow any to any'
- Regular review — remove stale rules
DMZ traffic flows:
- Internet → DMZ: specific ports to specific servers only
- DMZ → Internal: deny by default, allow only app-to-db flows
- Internal → Internet: through perimeter FW with content filtering
Zero trust:
- Never trust, always verify
- Identity-aware proxies replace network location as access control
- Least privilege, just-in-time access
- Encrypt everything (TLS, mTLS)
Tags: defense, firewall
Continue Learning
Before You Start
- No prerequisites listed.