Skip to content
Tutorials Center
My learning

Topics

Lesson 32 of 37 ยท Design and Operations

Defense in Depth Architecture

Design a layered network: zones, DMZ, management plane, segmentation rules and monitoring. Model an architecture as data and test it automatically for missing controls and risky paths.

No single control stops every attack. Firewalls miss encrypted exploits, patching lags behind disclosure, users click links, and administrators make mistakes. Defense in depth accepts this and stacks independent controls so that when one fails, the next one still stands between the attacker and the asset. The goal is not a perfect wall but to make an intrusion slow, noisy and contained.

This lesson turns the principle into an architecture: how to divide a network into zones, how traffic is allowed between them, where the management plane lives, and how to test your design. We model a small company network as data in Python and check it for typical design flaws.

The layers

Think of concentric layers, from the data outward:

Layers of defense

Policy and people Rules, training, reviews
Perimeter Firewall, DDoS, filtering
Network Zones, segmentation, IDS
Host Hardening, EDR, patching

Each layer assumes the one outside it failed.

1 / 2

Layers should be diverse: two firewalls from the same vendor with the same bug are one layer, not two. And they should fail safely and visibly: when a control stops working you want an alarm, not silence.

Zones and trust levels

A zone is a group of systems with similar trust and exposure. Traffic between zones passes through a control point (a firewall, a router ACL or cloud security group) with explicit rules.

flowchart TB
    Internet(["Internet"]) --> FW1["Edge firewall"]
    FW1 --> DMZ["DMZ<br/>web, mail relay, reverse proxy"]
    FW1 --> VPN["Remote access gateway"]
    DMZ --> FW2["Internal firewall"]
    VPN --> FW2
    FW2 --> APP["Application zone"]
    FW2 --> DB["Data zone<br/>databases"]
    FW2 --> USERS["User zone<br/>laptops, printers"]
    FW2 --> MGMT["Management zone<br/>admin jump hosts, logging, backup"]
    GUEST["Guest Wi-Fi / IoT"] --> FW1

Public services live in the DMZ; data is two hops from the internet; guests and IoT never touch the internal zones.

Typical zones:

  • Internet / untrusted. Everything outside.
  • DMZ. Servers that must be reachable from outside (web front end, mail gateway). They are assumed to be attacked first, so they hold no secrets and can only reach specific internal services.
  • Application and data zones. Business logic and databases. Databases accept connections only from the application tier.
  • User zone. Workstations. They can reach applications but not the data zone directly, and cannot connect to each other (which blocks worm-style spread).
  • Management zone. Administrative tooling, jump hosts, the SIEM, backup systems. Treated as the most sensitive zone: whoever controls it controls everything.
  • Guest and IoT zones. Internet access only, nothing internal.

Rules of thumb for zone rules

  1. Default deny between zones, allow by exact source, destination and port.
  2. Allow flows along the dependency chain only: user to web, web to app, app to database. Skipping a tier (web directly to the database) is a smell.
  3. No direct inbound from the internet to inside. Only the DMZ is reachable.
  4. Outbound control too. Servers rarely need to browse the web; restrict egress so malware cannot call out freely and data cannot leave quietly. Many breaches are found by watching for unexpected outbound connections.
  5. Management traffic arrives only from the management zone, over encrypted protocols, with MFA (SSH hardening).
  6. Log every denied flow at zone boundaries and send the logs to the SIEM.

Testing the design in code

Design reviews are more reliable when the design is data. The program below models zones and allowed flows, then checks for common mistakes: direct internet access to protected zones, tier skipping, missing egress restrictions, and flows into the management zone from untrusted places.

Python Check a zone design for risky flows

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Four of the ten flows are flagged (five findings, because the internet-to-management flow trips two checks). Each finding is a design conversation: fix the flow, or document why it is an accepted risk. Running a check like this in a pipeline each time firewall rules change prevents "rule creep".

Avoiding single points of failure

Depth is about security, but availability is part of security too.

  • Redundant firewalls, links and power. Decide fail-open versus fail-closed per zone, as discussed in IDS and IPS.
  • Offline or immutable backups, tested by restoring; ransomware targets backup systems first.
  • Separate out-of-band management (console server, separate network) so you can fix the network when the main network is down or under attack.
  • Capacity and DDoS protection (upstream scrubbing, rate limits, CDN).

Operating the design

An architecture decays unless it is maintained:

  1. Document it: diagrams, zone list, owner of each firewall rule, expiry dates on temporary rules.
  2. Review rules periodically; delete unused ones (counters show which rules never match).
  3. Change control: peer-review every firewall change; test in a staging environment.
  4. Validate with authorized assessments: vulnerability scans and penetration tests that try the paths your design claims are closed.
  5. Measure: alerts triaged, mean time to detect, mean time to contain. See vulnerability and patch management and incident response.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the main idea of defense in depth?

    Multiple diverse layers make an intrusion slower, noisier and more contained.
  2. 2. Why does the DMZ hold no secrets and have limited access inward?

    Assume DMZ hosts will be breached; limit what they hold and where they can connect.
  3. 3. Which flow in a three-tier design is a warning sign?

    Skipping the application tier widens attack paths; the web tier should only reach the application tier.
  4. 4. Why restrict outbound (egress) traffic from servers?

    Most intrusions need outbound connectivity for command and control or data theft; egress control blocks it.
  5. 5. Why is the management zone often the most sensitive?

    Jump hosts, backups and logging systems have broad privileges, so their compromise is catastrophic.

Summary

  • Defense in depth stacks diverse, independent controls across policy, perimeter, network, host, application, data and identity.
  • Divide the network into zones (DMZ, application, data, users, management, guest) with default-deny rules along the dependency chain.
  • Control egress as well as ingress, protect the management plane, and log denied flows.
  • Model the design as data and test it automatically for risky flows.
  • Plan for availability: redundancy, tested backups, out-of-band management.
  • Maintain the design with documentation, rule reviews, change control and authorized testing.

Next: Vulnerability and Patch Management