24 Firewall with a DMZ
A three-zone firewall: the outside reaches only the web server in the DMZ, and only the web server reaches the database.
What you practice
- Zones and a default-drop forward policy in nftables
- Testing a policy from each side, and reading the drop log
- Hosts with no management NIC: everything goes through the firewall
Topology
| Node | Image | CPUs / memory | Addresses | Role |
|---|---|---|---|---|
client | debian-13 | 1 / 1GiB | mgmt 10.124.0.11 | Outside host |
fw | debian-13 | 1 / 1GiB | mgmt 10.124.0.12; dmz 192.168.50.1/24; inside 192.168.60.1/24 | Firewall, three zones |
web | debian-13 | 1 / 1GiB | dmz 192.168.50.10/24 | DMZ web server |
db | debian-13 | 1 / 1GiB | inside 192.168.60.10/24 | Inside database |
Before you start
bash
vz image pull disk debian-13Run it
bash
cd examples/24-firewall-dmz
vz validate
vz up
vz node ls
ssh lab@10.124.0.11 # password: labFirst boot installs packages; give it a minute or two after vz up returns.
Try it
bash
ssh lab@10.124.0.11 'curl -s http://192.168.50.10' # allowed
ssh lab@10.124.0.11 'nc -zv -w 2 192.168.60.10 5432' # dropped
ssh lab@10.124.0.12 'sudo journalctl -k -g "fw drop" | tail -3' # the log line
vz node console web
# PGPASSWORD=app psql -h 192.168.60.10 -U app -c 'select now()' # allowed from the DMZ
ssh lab@10.124.0.11 'sudo nmap -Pn -p 22,80,5432 192.168.50.10 192.168.60.10'Notes
web and db have no mgmt NIC; reach them with vz node console. They install their packages through the firewall once it is up, so they finish a little after the others.
Clean up
bash
vz down
vz destroy --yes # deletes the overlays and state of this lab