What a DMZ is and how to build one
This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.
Key points
- A DMZ is a separate network between the internet and the internal network: servers that must be visible from the internet stand there.
- The main idea: even if a DMZ server is compromised, there must be no way from it into the LAN. That is why DMZ → LAN is closed by default.
- On a FortiGate a DMZ is an ordinary interface (a separate port or a VLAN) with its own subnet. Everything between the zones is decided by firewall policies.
role dmzaffects only how the GUI looks; it gives no security. Policies give security.- Do not enable management access (HTTPS, SSH) on the DMZ port: a compromised server must not reach the FortiGate's login page.
The problem
A company has a web site, a mail server or a customer portal, and they must open from the internet. The easiest way would be to put the server into the office network (LAN) and forward a port. It works, but it is dangerous.
An internet-facing server is under constant attack. If one day a vulnerability is found and the server is taken over, the attacker is already inside the LAN: the file server, the accounting database and the staff computers are in the same network with it, with no firewall in between.
The solution: a middle zone
A DMZ (demilitarized zone) is a third, separate network. Servers that must be visible from the internet are moved there.
Internet │ port1 (WAN) ┌────┴────┐ │ FGT-HQ ├── port3 (DMZ) ── web server, mail └────┬────┘ 10.10.30.0/24 │ port2 (LAN) staff, database, file server 10.10.10.0/24
Now there are three zones and the FortiGate stands between every pair. If a DMZ server is compromised, the attacker stays inside the DMZ: to get into the LAN they must pass the firewall again, and there they have no permission.
Trust levels and the traffic table
| Zone | Trust | Who is there |
|---|---|---|
| WAN (internet) | None | Everyone |
| DMZ | Low | Internet-facing servers |
| LAN | High | Staff, internal servers, data |
The general rule: a higher-trust zone may go to a lower one, not the other way round.
| From → To | Default | Why |
|---|---|---|
| WAN → DMZ | Only the published ports (for example 443) | The site must open, nothing else |
| WAN → LAN | Closed | There must be no direct way from the internet into the LAN |
| LAN → DMZ | The services that are needed | Staff open the site, an admin manages the server |
| DMZ → LAN | Closed (one or two narrow exceptions at most) | This is the whole point of a DMZ |
| DMZ → WAN | Limited (updates, DNS) | A compromised server must not go out freely |
| LAN → WAN | Open (with profiles) | Ordinary internet use |
In the next three lessons we turn this table into policies line by line.
What goes into the DMZ and what does not
| In the DMZ | In the LAN |
|---|---|
| Web server, customer portal | Database |
| Mail-receiving server (relay) | File server |
| Public DNS server | Active Directory |
| Reverse proxy | Accounting and HR systems |
A typical layout: the web server is in the DMZ and the database it uses is in the LAN. The web server is allowed to reach only one port (the database port) of one address in the LAN. We write this in lesson 49.
The DMZ port on a FortiGate
To a FortiGate a DMZ is nothing special: it is an ordinary interface that simply has its own subnet. Some models have a port labelled "DMZ", but any free port can become the DMZ.
FGT-HQ # config system interface FGT-HQ (interface) # edit "port3" FGT-HQ (port3) # set ip 10.10.30.1 255.255.255.0 FGT-HQ (port3) # set alias "DMZ" FGT-HQ (port3) # set role dmz FGT-HQ (port3) # set allowaccess ping FGT-HQ (port3) # next FGT-HQ (interface) # end
| Line | Meaning |
|---|---|
set ip | This address will be the default gateway of the DMZ servers |
set alias | The name shown next to the port in the GUI |
set role dmz | Tells the GUI what the port is for and hides some unneeded options. It does not affect traffic |
set allowaccess ping | From the DMZ to the FortiGate itself only ping. No HTTPS or SSH |
The last line matters. On the LAN port we enabled https ssh so that an admin could manage the device (lesson 5). Do not do that in the DMZ: a compromised server must not see the FortiGate's login page.
If there is no free port, the DMZ can also be created as a VLAN (lesson 5): for example VLAN 30 on port2. The logic is the same: a separate interface, a separate subnet.
GUI: Network > Interfaces > port3, Role: DMZ.
Address objects
Let us create the network and the server as objects for use in policies:
FGT-HQ # config firewall address FGT-HQ (address) # edit "DMZ-NET" FGT-HQ (DMZ-NET) # set subnet 10.10.30.0 255.255.255.0 FGT-HQ (DMZ-NET) # next FGT-HQ (address) # edit "SRV-WEB" FGT-HQ (SRV-WEB) # set subnet 10.10.30.10 255.255.255.255 FGT-HQ (SRV-WEB) # next FGT-HQ (address) # end
On the server side
Give a DMZ server a static address (no DHCP): IP 10.10.30.10/24, default gateway 10.10.30.1. Policies and the VIP will be tied to this address, so it must not change.
What works now?
Nothing. The port is ready, but there is no policy involving port3, so the implicit deny (lesson 8) drops everything. The DMZ is still fully isolated, and that is the right starting point: we will open only what is needed, one thing at a time.
FGT-HQ # show system interface port3 FGT-HQ # execute ping 10.10.30.10
A ping from the FortiGate itself to the server works (they are in the same network), while nothing passes yet from the LAN or from the internet.
Common mistakes
| Mistake | Result |
|---|---|
A "temporary" DMZ → LAN all policy | The DMZ loses its meaning; if the server is compromised, the LAN is open |
allowaccess https ssh on the DMZ port | Attacks on the FortiGate's management from a compromised server |
| DMZ and LAN on the same switch without VLANs | Servers bypass the FortiGate and reach the LAN |
| Handing out DMZ addresses by DHCP | The server's address changes; the policy and VIP stop working |
DMZ → internet open to all | A compromised server freely receives commands and sends data out |
🧪 Hands-on lab · Device: FortiGate-VM
The DMZ interface and addresses
Prepare port3 as the DMZ: IP 10.10.30.1/24, alias DMZ, role dmz, management access ping only. Then create two address objects: DMZ-NET (10.10.30.0/24) and SRV-WEB (10.10.30.10/32). Finally check with show system interface port3.
Checked:
- port3: 10.10.30.1/24
- role dmz
- allowaccess: ping
- DMZ-NET
- SRV-WEB
Check yourself
5 questions · answers are shown instantly · 3 correct answers complete the lesson
1What is the main purpose of a DMZ?
2Which direction should stay closed by default?
3How does set role dmz affect traffic?
4Why should you not enable allowaccess https ssh on the DMZ port?
5The port is ready but no policy has been written for port3. Does traffic pass from the LAN to the DMZ server?
Comments
Sign in to comment.