A DMZ isn’t just a firewall rule set; it’s a strategically isolated zone designed to expose your less trusted services to the outside world while keeping your internal network shielded.

Imagine you’re running a web server that needs to be accessible from the internet. You could just put it on your internal network, but that would mean opening up direct access from the internet all the way into your sensitive internal systems if that web server ever got compromised. Instead, you put it in a DMZ.

Here’s a simplified setup:

[Internet] <--> [Firewall 1] <--> [DMZ Network] <--> [Firewall 2] <--> [Internal Network]
  • Firewall 1 (the "external" firewall) permits traffic from the Internet only to the specific services running in the DMZ (e.g., port 80/443 for a web server). It blocks everything else.
  • Firewall 2 (the "internal" firewall) permits traffic from the DMZ only to the specific services in the DMZ that need to talk to internal systems (e.g., a web server needing to query a database). Crucially, it blocks traffic from the DMZ to the internal network unless absolutely necessary and very strictly controlled. It also blocks unsolicited inbound traffic from the internet entirely.

Let’s say you have an external-facing web application.

Internet (External User): Requests GET /index.html to your-public-ip.

Firewall 1: Inspects the packet. Source IP is from the Internet. Destination IP is your public IP. Destination port is 443 (HTTPS). This is allowed. Packet forwarded to the DMZ interface.

DMZ Network: The packet arrives at the IP address of your web server (e.g., 192.168.10.10). The web server software (like Nginx or Apache) receives the request.

Web Server (DMZ): Processes the request. If it needs data from an internal database, it initiates a new connection.

Firewall 2: Inspects this new packet. Source IP is the web server (192.168.10.10). Destination IP is the internal database server (e.g., 10.0.0.50). Destination port is 5432 (PostgreSQL). This specific connection (DMZ to Internal DB on port 5432) is allowed by a rule on Firewall 2. Packet forwarded to the Internal Network.

Internal Network: The database server receives the query and sends a response back.

Firewall 2: The response packet is from the internal DB server (10.0.0.50) to the web server (192.168.10.10) on port 5432. This is allowed because it’s part of an established, stateful connection.

DMZ Network: Web server receives the data and constructs the HTML response.

Firewall 1: The web server sends the response packet back towards the Internet. Firewall 1 sees it’s a response to an established connection originating from the DMZ and allows it out to the Internet.

Internet (External User): Receives the HTML response.

The key here is that the internet user never directly connects to the internal database server. If the web server in the DMZ is compromised, the attacker’s access is limited to the DMZ. They would then need to breach Firewall 2 to get to the internal network, which is a much harder second step.

The whole point of a DMZ is to create a buffer. You expose services that must be internet-facing (like web servers, mail servers, VPN endpoints) in this isolated zone. Then, you carefully control what, if any, communication those DMZ services can initiate back into your trusted internal network. This principle is often called the "principle of least privilege" applied to network segmentation. Any service in the DMZ that doesn’t need to talk to the internal network should have that communication explicitly blocked.

One of the most common mistakes is to allow too much inbound traffic from the DMZ to the internal network. For instance, a web server in the DMZ might need to query a database. A common, but dangerous, rule would be to allow any traffic from the web server to the database subnet. A more secure approach is to allow only the specific port used by the database (e.g., TCP port 5432 for PostgreSQL) from the web server’s specific IP address to the database server’s specific IP address. This means if the web server is compromised and tries to scan for other services on the internal network, it will be blocked.

The next step after understanding DMZs is often implementing more granular security controls within the DMZ itself, such as host-based firewalls on the DMZ servers or intrusion detection systems.

Want structured learning?

Take the full Computer Networking course →