DMZ & containment

Publish a server from the DMZ

Lesson 9 of 20 · 12 min · Module 3: Zones and policies

A server that the internet can reach will be attacked. The DMZ exists so that when one is compromised, the attacker is not standing inside the office network.

Start this lesson →

Free. No installation: you write and run the code in your browser, and it is checked automatically.

By the end, you’ll be able to…

  • Publish a single service to the internet
  • Give the office and the administrator their own access
  • Contain a compromised DMZ server

The idea

A DMZ holds the servers that outsiders may reach. The policy around it has three parts: outsiders get one service on one server, the office gets what it needs, and the DMZ itself may start nothing toward trust.

allow tcp from untrust to mail port 25
deny any from dmz to trust log

01Publish one service, on one server

"allow tcp from untrust to web port 443" lets the internet reach the website and nothing else: not SSH on the web server, and not port 443 on the server next to it. Naming the zone dmz as the destination would publish every server in it.

02Contain the DMZ

If the web server is taken over, the next thing the attacker tries is a connection into the office. An explicit, logged "deny any from dmz to trust" blocks it and tells you it happened. The default deny would also block it, silently.

03The same policy on real devices

Each direction between two zones is its own policy. The publishing rule normally works together with address translation, which module 4 covers; for now the lab delivers internet packets straight to the server address.

# Huawei USG
security-policy
 rule name internet_to_web
  source-zone untrust
  destination-zone dmz
  destination-address 10.0.2.10 mask 255.255.255.255
  service https
  action permit
 rule name dmz_to_trust
  source-zone dmz
  destination-zone trust
  policy logging
  action deny

# nftables
nft add rule inet filter forward iifname "wan0" ip daddr 10.0.2.10 tcp dport 443 accept
nft add rule inet filter forward iifname "dmz0" oifname "lan0" log prefix "dmz-to-lan: " drop

Your turn

Write the DMZ policy. The internet (untrust) may reach web on tcp 443. The office (trust) may reach web on tcp 443 too. Only admin may use SSH (tcp 22) to the dmz. The DMZ may start nothing toward trust: deny and log it with an explicit rule.

What the checks look for

  • The internet reaches the website on 443 and nothing else
  • The office reaches the website
  • Only the administrator has SSH to the DMZ
  • A logged rule stops the DMZ from reaching the office
Try it in the editor →

Take this with you

Publish one service on one server, and stop the DMZ from starting connections into the office with a rule that logs.

Go a little further

The web application will need its database one day. Think about which single rule you would add, and why the database should not sit in the DMZ.

Learn Firewall Foundations for free

20 short lessons with real code and instant checks.

See the whole course →