18 – Operational Security: Firewalls, IDS/IPS, DMZ, VPN and Zero Trust
Course: ICT Basic course · Level: introductory Book: Kurose & Ross, 9th ed., chapter 8.7 (network-layer security: IPsec and VPNs), 8.8 (securing wireless LANs), 8.9 (operational security: firewalls and IDS)
Learning goals
After this article you can:
- explain the purpose of a firewall and the differences between stateless packet filters, stateful filters, application gateways/proxies and next-generation firewalls;
- read and write simple firewall rules (default deny);
- explain the difference between an IDS and an IPS, and between signature-based and anomaly-based detection;
- design a simple network with a DMZ;
- explain how a VPN works (IPsec, TLS-based, WireGuard) and when to use it;
- explain the idea of Zero Trust and why the "castle and moat" model is no longer enough.
1. Firewalls
A firewall isolates an organisation's internal network from the Internet (or one zone from another), allowing some packets to pass and blocking others.
Goals: - prevent unauthorised access to internal systems; - allow only authorised traffic (as defined in the security policy); - limit damage (e.g. stop DoS traffic, stop malware from "calling home"); - the firewall itself must be hardened against attacks.
1.1 Types of firewalls
| Type | Looks at | Example decision |
|---|---|---|
| Stateless packet filter | each packet on its own: source/destination IP, protocol, ports, TCP flags | "block all incoming TCP with SYN flag to port 23" |
| Stateful packet filter | also the state of connections (connection table) | "allow incoming packets only if they belong to a connection that was started from inside" |
| Application gateway / proxy | application data (e.g. HTTP requests, users) | "only these users may use SSH"; web proxy that blocks malware sites |
| Next-Generation Firewall (NGFW) | everything above + application identification, user identity, IPS, TLS inspection, threat intelligence | "allow Microsoft Teams, block BitTorrent, for group students" |
| Web Application Firewall (WAF) | HTTP(S) to web apps | block SQL injection or XSS attempts |
| Host-based firewall | traffic of one host | Windows Defender Firewall, nftables/ufw on Linux, macOS firewall |
Still in use? Simple stateless filters (ACLs) are still widely used on routers and in cloud networks (e.g. AWS Network ACLs), but on their own they're not enough. Stateful filtering is the minimum; NGFWs are the standard at the edge of company networks; and in the cloud, security groups do stateful filtering per server.
1.2 Firewall rules (access control list)
Rules are checked from top to bottom; the first match decides. The last rule should be default deny.
| # | Action | Source | Destination | Protocol | Dest. port | Purpose |
|---|---|---|---|---|---|---|
| 1 | allow | any | 203.0.113.10 (web server, DMZ) | TCP | 443 | public website (HTTPS) |
| 2 | allow | any | 203.0.113.10 | UDP | 443 | HTTP/3 |
| 3 | allow | 10.0.0.0/16 (internal) | any | TCP | 80, 443 | staff browse the web |
| 4 | allow | 10.0.0.0/16 | 10.0.99.5 (internal DNS) | UDP/TCP | 53 | DNS |
| 5 | allow | established/related | any | any | any | return traffic (stateful) |
| 6 | deny | any | any | any | any | default deny (and log) |
Linux example with ufw (a simple front end for nftables):
1 2 3 4 5 6 | |
On Linux, nftables is the modern framework; iptables is the older one (still found a lot, often running on top of nftables now).
Egress filtering (filtering outgoing traffic) is just as important: it stops malware from connecting to its command-and-control server and stops data leaks.
2. Intrusion Detection and Prevention (IDS / IPS)
A firewall mostly looks at headers. An IDS does deep packet inspection: it also looks at the content and correlates many packets.
| IDS (Intrusion Detection System) | IPS (Intrusion Prevention System) | |
|---|---|---|
| Action | detects and alerts | detects and blocks |
| Placement | passive, on a copy of the traffic (SPAN port / tap) | inline, in the traffic path |
| Risk | attack still gets through | a false positive blocks legitimate traffic |
Detection methods: - Signature-based: compares traffic with a database of known attack patterns (like antivirus). Accurate for known attacks, blind to new ones (zero-days). - Anomaly-based: learns what "normal" traffic looks like and alerts on deviations (sudden scanning, unusual data volumes, connections at night). Can detect new attacks, but gives more false positives.
Tools: Suricata, Snort and Zeek (open source), and IPS functions built into NGFWs. Network IDS is often combined with EDR/XDR on endpoints and a SIEM (collecting and correlating logs), operated by a SOC (Security Operations Centre).
3. The DMZ
Servers that must be reachable from the Internet (web server, mail server, public DNS) are a risk: if they're hacked, the attacker shouldn't be inside the internal network immediately. Solution: put them in a separate zone, the DMZ (demilitarised zone).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
(Often implemented with one firewall that has three interfaces: Internet, DMZ, internal.)
Rules of thumb: - Internet → DMZ: only the needed services (e.g. 443). - DMZ → internal: as little as possible (e.g. only the web server to the database on one port). - Internal → DMZ: management via a protected management network.
In the cloud, the same idea is implemented with public and private subnets, security groups and load balancers.
4. VPN – Virtual Private Network
A VPN creates an encrypted tunnel over a public network (the Internet), so that remote users or sites can communicate as if they were on a private network.
| Type | Use |
|---|---|
| Site-to-site VPN | connects the networks of two offices or an office and a cloud network |
| Remote-access VPN | connects an employee's laptop to the company network |
| Consumer "privacy" VPN | hides your traffic from the local network/ISP (but the VPN provider can see it) |
VPN technologies
| Technology | Layer | Notes |
|---|---|---|
| IPsec | network (3) | IETF standard; AH (authentication only, rarely used) and ESP (encryption + integrity); tunnel mode (whole IP packet encapsulated, typical for site-to-site) and transport mode; keys set up with IKEv2. Widely used for site-to-site VPNs |
| TLS/SSL VPN | above transport | e.g. OpenVPN, Cisco AnyConnect, Fortinet/Palo Alto GlobalProtect. Works through almost every firewall (port 443) |
| WireGuard | network (over UDP) | modern, small and fast; uses Curve25519, ChaCha20-Poly1305; built into the Linux kernel; used by Tailscale and many VPN providers |
| PPTP, L2TP without IPsec | – | legacy and insecure: don't use |
1 2 3 | |
Updated: VPN appliances have become a favourite target of attackers: in recent years there have been many actively exploited vulnerabilities in the VPN gateways of large vendors. Patch them immediately, use MFA, and consider zero-trust alternatives.
5. Zero Trust (updated)
The classic model is "castle and moat": a strong firewall at the edge, and everything inside is trusted. That doesn't work well any more:
- users work from home and use cloud services (SaaS), so there's no clear "inside";
- once an attacker is inside (phishing, VPN vulnerability), they can move freely (lateral movement).
Zero Trust (NIST SP 800-207): "never trust, always verify".
- Every access request is checked: who (strong identity + MFA), which device (managed, up to date, healthy?), what (least privilege), context (location, time, risk).
- No automatic trust based on network location: being on the company Wi-Fi does not give access to everything.
- Micro-segmentation: small zones, ideally per application or workload.
- Assume breach: monitor and log everything.
Implementations: ZTNA (Zero Trust Network Access) instead of a classic VPN, identity providers with conditional access (Microsoft Entra ID, Okta), SASE/SSE (cloud-delivered firewall, secure web gateway and ZTNA).
Zero Trust doesn't replace firewalls and VPNs entirely; it's a strategy that combines identity, devices, networks and data.
6. Wireless security (short)
| Protocol | Status |
|---|---|
| WEP (1999) | broken in minutes, never use |
| WPA (TKIP) | broken/deprecated |
| WPA2-AES (CCMP) | still acceptable with a strong passphrase; vulnerable to offline password guessing and KRACK (patched) |
| WPA3 (2018) | current: SAE handshake (resistant to offline guessing), forward secrecy, required for Wi-Fi 6E/7 on 6 GHz |
| WPA2/WPA3-Enterprise (802.1X) | per-user authentication via RADIUS (e.g. eduroam) |
7. Try it yourself
- Configure ufw on your VM (section 1.2). Test from your host with
nc -vz <vm-ip> 22and another port. What happens with a blocked port: a timeout or a "connection refused"? - Write a firewall rule table for a small company with a web server in a DMZ, a mail server, 30 staff PCs and a database server.
- IDS: install Suricata on your VM (
sudo apt install suricata) and update the rules (sudo suricata-update). Add your own test rule to/etc/suricata/rules/local.rules(and addlocal.rulestorule-filesin/etc/suricata/suricata.yaml):Restart Suricata (1alert icmp any any -> any any (msg:"TEST: ICMP ping detected"; itype:8; sid:1000001; rev:1;)sudo systemctl restart suricata), ping the VM from your host, and check/var/log/suricata/fast.log. - VPN: set up a WireGuard tunnel between two VMs (see the WireGuard quick start), or try Tailscale. Capture the traffic in Wireshark: what can you still see?
Check your understanding
- What is the difference between a stateless and a stateful packet filter?
- Why should the last firewall rule be "deny all"?
- Why is egress filtering useful?
- Give one advantage and one disadvantage of signature-based and of anomaly-based detection.
- Which servers do you put in a DMZ, and why?
- What is the difference between IPsec tunnel mode and transport mode?
- Explain "never trust, always verify".
References
Book
- Kurose & Ross, 9th ed., chapter 8.7–8.9
Videos
- PowerCert – What is a Firewall? https://www.youtube.com/watch?v=kDEX1HXybrU
- PowerCert – VPN (Virtual Private Network) Explained https://www.youtube.com/watch?v=R-JUOpCgTZc
- IBM Technology – Zero Trust Explained in 4 mins https://www.youtube.com/watch?v=yn6CPQ9RioA
- Computerphile – How TOR Works (anonymity networks vs. VPNs) https://www.youtube.com/watch?v=QRYzre4bf7I
- Professor Messer – CompTIA Network+ N10-009 (security sections) – https://www.youtube.com/playlist?list=PLG49S3nxzAnl_tQe3kvnmeMid0mjF8Le8
Articles, standards and tools
- NIST SP 800-207 – Zero Trust Architecture – https://csrc.nist.gov/pubs/sp/800/207/final
- CISA – Zero Trust Maturity Model – https://www.cisa.gov/zero-trust-maturity-model
- WireGuard – https://www.wireguard.com/
- Suricata – https://suricata.io/ · Zeek – https://zeek.org/
- Debian wiki – nftables – https://wiki.debian.org/nftables
- RFC 4301 – Security Architecture for IP (IPsec) – https://www.rfc-editor.org/rfc/rfc4301
Cyber Security
Why is this important for cyber security?
These are the core tools of operational network security. Almost every organisation (and every home router) has a firewall; every remote worker uses a VPN or ZTNA; and every serious organisation monitors its network. But:
- Misconfiguration is one of the most common causes of breaches: "allow any any" rules added "temporarily", forgotten port forwards, management interfaces reachable from the Internet.
- Security devices are targets themselves: firewalls and VPN gateways sit at the edge, are reachable from the Internet and hold the keys to the network, so vulnerabilities in them are exploited within days.
- A firewall doesn't stop everything: phishing, stolen credentials, malicious insiders and encrypted malware traffic can pass through allowed ports. That's why you need defence in depth and detection (IDS, EDR, SIEM).
- Remote work made the network perimeter disappear, which is why identity-based (Zero Trust) security is now essential.
What can you do to make it safe?
- Default deny, both incoming and outgoing; document why every rule exists, and review rules regularly (remove what's no longer needed).
- Segment the network (DMZ, VLANs, micro-segmentation) and filter between zones.
- Patch firewalls and VPN gateways immediately when critical updates appear; subscribe to vendor and NCSC advisories.
- MFA for every remote access (VPN, ZTNA, admin portals), preferably phishing-resistant.
- Never expose management interfaces of firewalls, routers or servers to the Internet.
- Log and monitor: send firewall/IDS logs to a SIEM, tune rules against false positives, and actually respond to alerts.
- Test: vulnerability scans and penetration tests (with permission!), and check your external attack surface regularly.
- At home: keep the router's firewall on, disable UPnP and remote management, use WPA3, put IoT devices on a guest network, and be critical of "privacy VPN" marketing.
Extra references
- NCSC-NL – advisories and factsheets (e.g. on securing VPNs and edge devices) – https://www.ncsc.nl/
- CISA – Known Exploited Vulnerabilities Catalog – https://www.cisa.gov/known-exploited-vulnerabilities-catalog
- CIS Controls v8 – https://www.cisecurity.org/controls
- MITRE ATT&CK – https://attack.mitre.org/