| |

LFCE 5 ๐Ÿง Network Architecture โ€” LAN, WAN, DMZ

โฑ๏ธ Estimated read: 10 min | |

The LFCE exam is retired, but its curriculum remains the benchmark for advanced Linux engineering. The Networking domain (15%) required understanding how to connect and secure systems across different trust boundaries. Network architecture is the foundation for those tasks: a LAN is the trusted internal network, a WAN connects geographically separated sites, and a DMZ is a buffer zone that exposes public services without compromising the internal network.

Key point: The LFCE tested the ability to configure a Linux system as a router and firewall, which requires understanding the flow of traffic between the LAN, the WAN, and the DMZ. The DMZ is not a physical location; it is a logical network segment defined by firewall rules that isolate public-facing services from the internal LAN.


Why network architecture matters for Linux engineering

The trust boundary problem. The LAN contains the internal systems: workstations, databases, and internal application servers. These systems trust each other and often run services that should never be exposed to the internet. The WAN is the untrusted networkโ€”the internet or a public transit link. The DMZ sits between them. It hosts the services that must be reachable from the WAN, such as a web server or a reverse proxy, but it is isolated from the LAN by the firewall. If the web server in the DMZ is compromised, the attacker cannot pivot directly into the LAN.

The routing problem. A Linux system acting as the gateway between these networks must perform Network Address Translation (NAT) for the LAN to reach the internet, and it must route traffic between the DMZ and the WAN without exposing the LAN. The LFCE Networking objectives included “Configure a system to perform Network Address Translation” and “Dynamically route IP traffic,” which are the mechanisms that make the LAN-WAN-DMZ topology work.

The firewall problem. The firewall rules define the architecture. A default-deny policy on the forwarding chain, with explicit allow rules for the DMZ services and the LAN-to-WAN traffic, is the standard implementation. The LFCE tested “advanced packet filtering,” which in this context means writing the rules that enforce the separation between the three zones.

The DMZ service problem. The services in the DMZ are deliberately exposed. A reverse proxy in the DMZ can terminate TLS and forward requests to the internal application servers in the LAN, which means the internal servers never accept direct connections from the WAN. This is the “host-based and user-based security for a service” objective from the LFCE Service Configuration domain.

The trade-off. A flat network with no DMZ is simpler to configure but exposes every internal system to the WAN. A three-zone architecture requires more firewall rules and more careful routing, but it limits the blast radius of a compromise. The LFCE expected the engineer to design the three-zone architecture and implement it with Linux tools.


a. The LAN, WAN, and DMZ topology

The standard three-zone topology uses a Linux gateway with at least two network interfaces: one connected to the WAN, one to the LAN, and optionally a third for the DMZ. The DMZ is often a separate VLAN or a separate physical interface on the gateway.

# The gateway interfaces
# eth0: WAN (public IP, e.g., 203.0.113.10/24)
# eth1: LAN (private IP, e.g., 192.168.1.1/24)
# eth2: DMZ (private IP, e.g., 192.168.2.1/24)

# Enable IP forwarding (runtime)
sudo sysctl -w net.ipv4.ip_forward=1

# Make it persistent
echo "net.ipv4.ip_forward = 1" | sudo tee /etc/sysctl.d/99-forwarding.conf
sudo sysctl --system

The net.ipv4.ip_forward=1 enables the kernel to forward packets between interfaces. Without it, the gateway drops all traffic that is not destined for itself. The persistent drop-in file ensures the setting survives a reboot.

The LAN hosts use the gateway as their default route. The DMZ hosts use the DMZ interface address as their gateway. The WAN hosts reach the DMZ services through the public IP and the NAT rules on the gateway.


b. Network Address Translation (NAT)

NAT is the mechanism that allows the LAN hosts to reach the WAN while hiding their private addresses. The gateway rewrites the source address of outbound packets to its public IP and tracks the connections to route the replies back.

# The nftables NAT rule (modern)
sudo nft add table ip nat
sudo nft add chain ip nat postrouting { type nat hook postrouting priority 100 \; }
sudo nft add rule ip nat postrouting ip saddr 192.168.1.0/24 oifname "eth0" masquerade

# The iptables alternative
sudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE

The masquerade target rewrites the source address to the outgoing interface’s address. The -s 192.168.1.0/24 limits the rule to the LAN subnet. The DMZ does not use NAT for inbound traffic; the public services are exposed through DNAT (destination NAT) or a reverse proxy.

The DNAT rule for a DMZ web server.

# Forward WAN port 80 to the DMZ web server
sudo nft add rule ip nat prerouting iifname "eth0" tcp dport 80 dnat to 192.168.2.10:80

# The iptables alternative
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 192.168.2.10:80

The prerouting chain processes the packet before the routing decision. The dnat target rewrites the destination address to the DMZ server. The reply from the DMZ server is rewritten back to the WAN client by the connection tracking.


c. The firewall rules that enforce the zones

The firewall rules are the enforcement mechanism. The default policy should be drop for the forwarding chain, with explicit allow rules for the required traffic.

# The nftables ruleset (simplified)
sudo nft add table ip filter
sudo nft add chain ip filter forward { type filter hook forward priority 0 \; policy drop \; }

# Allow established connections (the replies)
sudo nft add rule ip filter forward ct state established,related accept

# Allow the LAN to the WAN
sudo nft add rule ip filter forward iifname "eth1" oifname "eth0" accept

# Allow the WAN to the DMZ web server (port 80)
sudo nft add rule ip filter forward iifname "eth0" oifname "eth2" ip daddr 192.168.2.10 tcp dport 80 accept

# Allow the DMZ to the LAN database (specific service)
sudo nft add rule ip filter forward iifname "eth2" oifname "eth1" ip daddr 192.168.1.50 tcp dport 3306 accept

The ct state established,related rule allows the reply traffic from the outbound connections. The iifname and oifname match the input and output interfaces, which is the zone identifier. The DMZ-to-LAN rule is deliberately narrow: only the specific database host and port are allowed.

The policy drop on the forward chain is the default-deny. A packet that does not match any allow rule is dropped. This is the architecture in code: the LAN, WAN, and DMZ are separated by the rules, not by the physical topology.


Complete Example Session

# ============================================
# PART 1: ENABLE IP FORWARDING
# ============================================

sudo sysctl -w net.ipv4.ip_forward=1
echo "net.ipv4.ip_forward = 1" | sudo tee /etc/sysctl.d/99-forwarding.conf
sudo sysctl --system
# ============================================
# PART 2: THE NAT FOR THE LAN
# ============================================

sudo nft add table ip nat
sudo nft add chain ip nat postrouting { type nat hook postrouting priority 100 \; }
sudo nft add rule ip nat postrouting ip saddr 192.168.1.0/24 oifname "eth0" masquerade
# ============================================
# PART 3: THE DNAT FOR THE DMZ WEB SERVER
# ============================================

sudo nft add chain ip nat prerouting { type nat hook prerouting priority -100 \; }
sudo nft add rule ip nat prerouting iifname "eth0" tcp dport 80 dnat to 192.168.2.10:80
# ============================================
# PART 4: THE FORWARD CHAIN
# ============================================

sudo nft add table ip filter
sudo nft add chain ip filter forward { type filter hook forward priority 0 \; policy drop \; }
sudo nft add rule ip filter forward ct state established,related accept
# ============================================
# PART 5: THE LAN TO WAN
# ============================================

sudo nft add rule ip filter forward iifname "eth1" oifname "eth0" accept
# ============================================
# PART 6: THE WAN TO DMZ
# ============================================

sudo nft add rule ip filter forward iifname "eth0" oifname "eth2" ip daddr 192.168.2.10 tcp dport 80 accept
# ============================================
# PART 7: THE DMZ TO LAN (NARROW)
# ============================================

sudo nft add rule ip filter forward iifname "eth2" oifname "eth1" ip daddr 192.168.1.50 tcp dport 3306 accept
# ============================================
# PART 8: VERIFY
# ============================================

sudo nft list ruleset
# ============================================
# PART 9: TEST
# ============================================

# From the LAN: curl http://203.0.113.10 (the WAN IP) โ†’ the DMZ web server
# From the DMZ: ssh to the LAN database โ†’ allowed on port 3306 only

The nine parts trace the three-zone architecture: the forwarding, the LAN NAT, the DMZ DNAT, the default-deny forward chain, the LAN-to-WAN allow, the WAN-to-DMZ allow, the narrow DMZ-to-LAN allow, the verification, and the test.


Quick Reference

The Zones

ZoneTrust LevelTypical Services
LANHighDatabases, internal apps
DMZMediumWeb servers, proxies
WANLowThe internet

The Gateway Interfaces

InterfaceZoneAddress
eth0WANPublic IP
eth1LANPrivate IP (e.g., 192.168.1.1)
eth2DMZPrivate IP (e.g., 192.168.2.1)

The NAT Types

TypeChainPurpose
SNAT/MasqueradepostroutingLAN to WAN
DNATpreroutingWAN to DMZ

The Firewall Policies

ChainPolicyPurpose
forwarddropDefault-deny
inputdropProtect the gateway
outputacceptGateway outbound

Best Practices

โœ… Do This:

sudo nft add chain ip filter forward { type filter hook forward priority 0 \; policy drop \; }
<!-- Default-deny on the forward chain -->           # โœ…
sudo nft add rule ip filter forward iifname "eth0" oifname "eth2" ip daddr 192.168.2.10 tcp dport 80 accept
<!-- Explicit allow for the DMZ web server -->        # โœ…
sudo nft add rule ip filter forward iifname "eth2" oifname "eth1" ip daddr 192.168.1.50 tcp dport 3306 accept
<!-- Narrow DMZ-to-LAN access -->                     # โœ…

โŒ Don’t Do This:

# Allow all forwarding
<!-- The DMZ can reach the LAN freely -->            # โŒ
# Expose the LAN database directly to the WAN
<!-- The DMZ is bypassed -->                         # โŒ
# Forget the established,related rule
<!-- The replies from the outbound connections drop --> # โŒ

Common Pitfalls

PitfallWhy It HappensFix
LAN cannot reach the WANNo masquerade ruleAdd the postrouting SNAT
WAN cannot reach the DMZNo DNAT or forward allowAdd the prerouting DNAT and the forward rule
The DMZ can reach everythingNo default-deny or broad allowSet policy drop and narrow rules
The replies dropNo established,related ruleAdd the stateful rule
The gateway is exposedNo input policySet policy drop on input

Real-World Examples

1. Enable Forwarding

sysctl -w net.ipv4.ip_forward=1

2. LAN Masquerade

nft add rule ip nat postrouting ip saddr 192.168.1.0/24 oifname "eth0" masquerade

3. DMZ DNAT

nft add rule ip nat prerouting iifname "eth0" tcp dport 80 dnat to 192.168.2.10:80

4. Default-Deny Forward

nft add chain ip filter forward { type filter hook forward priority 0 \; policy drop \; }

5. LAN to WAN

nft add rule ip filter forward iifname "eth1" oifname "eth0" accept

6. WAN to DMZ

nft add rule ip filter forward iifname "eth0" oifname "eth2" ip daddr 192.168.2.10 tcp dport 80 accept

7. DMZ to LAN

nft add rule ip filter forward iifname "eth2" oifname "eth1" ip daddr 192.168.1.50 tcp dport 3306 accept

8. Stateful

nft add rule ip filter forward ct state established,related accept

9. Verify

nft list ruleset

10. Test

curl http://203.0.113.10

Visual

The Three-Zone Topology

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  WAN (the internet)                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚ eth0
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Linux Gateway                               โ”‚
โ”‚  โ”œโ”€โ”€ IP forwarding enabled                   โ”‚
โ”‚  โ”œโ”€โ”€ NAT (masquerade, DNAT)                  โ”‚
โ”‚  โ””โ”€โ”€ Firewall (default-deny forward)         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚ eth1                  โ”‚ eth2
           โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  LAN (trusted)       โ”‚  โ”‚  DMZ (public)        โ”‚
โ”‚  โ”œโ”€โ”€ Database        โ”‚  โ”‚  โ”œโ”€โ”€ Web server      โ”‚
โ”‚  โ””โ”€โ”€ Internal apps   โ”‚  โ”‚  โ””โ”€โ”€ Reverse proxy   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The Firewall Enforcement

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Forward chain (policy drop)                 โ”‚
โ”‚                                              โ”‚
โ”‚  1. established,related โ†’ accept             โ”‚
โ”‚  2. LAN โ†’ WAN โ†’ accept                       โ”‚
โ”‚  3. WAN โ†’ DMZ (port 80) โ†’ accept             โ”‚
โ”‚  4. DMZ โ†’ LAN (port 3306) โ†’ accept           โ”‚
โ”‚  5. Everything else โ†’ drop                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

ItemValue
LANTrusted internal network
WANUntrusted external network
DMZPublic-facing buffer zone
GatewayLinux system with multiple interfaces
NAT (LAN)SNAT/masquerade on postrouting
NAT (DMZ)DNAT on prerouting
FirewallDefault-deny forward chain
Statefulct state established,related accept

Key takeaways:

  • The LAN is trusted; the WAN is not; the DMZ is the buffer. The DMZ hosts the services that must be reachable from the WAN without exposing the LAN.
  • The Linux gateway is the enforcement point. It forwards the traffic between the zones, performs the NAT for the LAN and the DNAT for the DMZ, and applies the firewall rules.
  • The forward chain is default-deny. The policy drop is the architecture. The explicit allow rules define the permitted traffic between the zones.
  • The stateful rule is mandatory. The ct state established,related accept allows the replies from the outbound connections. Without it, the LAN cannot browse the WAN.
  • The DMZ-to-LAN access is narrow. The DMZ should not have broad access to the LAN. A specific host and port (e.g., the database on 3306) is the limit.

Remember: The network architecture is the trust model. The LAN, the WAN, and the DMZ are the zones. The gateway is the enforcement. The NAT is the address translation. The firewall is the separation. The exam tested the ability to implement this architecture with the Linux tools, and the skills remain the foundation for the advanced Linux engineering.

Was this helpful?


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!