Skip to content

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 ​

NodeImageCPUs / memoryAddressesRole
clientdebian-131 / 1GiBmgmt 10.124.0.11Outside host
fwdebian-131 / 1GiBmgmt 10.124.0.12; dmz 192.168.50.1/24; inside 192.168.60.1/24Firewall, three zones
webdebian-131 / 1GiBdmz 192.168.50.10/24DMZ web server
dbdebian-131 / 1GiBinside 192.168.60.10/24Inside database

Before you start ​

bash
vz image pull disk debian-13

Run it ​

bash
cd examples/24-firewall-dmz
vz validate
vz up
vz node ls
ssh lab@10.124.0.11        # password: lab

First 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