Firewall Policy Versus What Is Listening
Why "the firewall is on" is not the same as "the service is protected". How to compare firewall rules with the sockets that are really open.
OpenVAPT Academy handout. Online, with the self-check quiz: https://openvapt.com/academy/p12.html. Offline: openvapt learn P12.
Read First: P3
You Will Be Able To
- Read incoming allow rules from ufw, nftables and iptables.
- Correlate firewall rules with listening sockets to find real exposure and stale rules.
- Explain how Docker's published ports bypass ufw and the INPUT chain.
Exposure Has Two Halves
A service is reachable from the internet when it listens on a non-loopback address and the firewall lets traffic to its port through. Checking either half alone misleads. A default-deny firewall with "allow 3306 from anywhere" exposes the database as much as no firewall at all. An allow rule for a port nothing listens on is a hole waiting for the next service.
OpenVAPT reads the listening sockets from /proc/net. It reads the incoming allow rules from ufw status verbose, nft list ruleset or iptables -S. Then it labels each socket: allowed from anywhere, allowed from a restricted source, blocked by default deny, or reachable because nothing filters it.
Stale Rules
Rules outlive the services they were added for. Each single-port allow rule should match something that listens; if it does not, delete it or write down why it stays. Ranges (for passive FTP or media) are reviewed by hand.
Docker and the Firewall
Docker writes its own iptables rules for published ports (-p 8080:80) into the nat table and the DOCKER chain. Traffic reaches them before ufw's rules or the INPUT policy. A container port can therefore be open to the world while ufw reports it denied. Publish on 127.0.0.1 behind a reverse proxy, or filter in the DOCKER-USER chain, which Docker evaluates first and never overwrites.
In Summary
A firewall rule only matters if it matches what is listening. Compare the two lists. Remove stale rules and close unexpected ports.
Apply It
These OpenVAPT checks put this module into practice. Open one to see its detection logic and source code.
| Check | Title | Severity |
|---|---|---|
NET-FW-003 | Firewall Allows Sensitive Services From Anywhere | High |
NET-FW-004 | Firewall Rules Open Ports With No Service | Low |
NET-FW-005 | Container Ports Bypass the Host Firewall | Medium |
NET-FW-006 | Firewall Exposure Map of Listening Services | Info |
Printable Worksheet · Teacher Answer Key · For Teachers · Print this page with your browser's Print command for a handout.
Also available as plain Markdown for notes, scripts and AI tools. Same facts, same source, no styling.
Lab
Run: openvapt demo --only NET-FW-,NET-LSN- --out p12 and read the exposure map in NET-FW-006 for both labs (--lab vulnerable and --lab hardened).On a test machine with ufw: ufw status verbose and ss -tlnp ; pair every ALLOW rule with a listening socket by hand.Explain in two sentences why ufw deny 8080 does not stop docker run -p 8080:80 nginx.
Check Yourself
Answers are checked in your browser and never stored or sent.
References
- NIST SP 800-41 Rev. 1, Guidelines on Firewalls and Firewall Policy
- Docker documentation, Packet filtering and firewalls
Adapted from the OpenVAPT Academy (openvapt.com), built by AI Cybersecurity Engineers, used under the OpenVAPT Source-Available Licence 1.3. Free teaching use under Teaching With OpenVAPT. Pre-release material may be wrong or unstable; use at your own risk.
Cite This Page
If this page helped your work, please cite it. The version and web address are filled in; the access date is today's date in your browser. Every other style, and when credit is required, is on How to Cite OpenVAPT.
OpenVAPT. (2026). P12: Firewall Policy Versus What Is Listening (Version 0.1.0-alpha.6). OpenVAPT Academy. Retrieved October 16, 2026, from https://openvapt.com/academy/p12.html
In text: (OpenVAPT, 2026). Accessed: the date shown is today's date from your own browser (the site's build date without JavaScript); change it to the day you read the page.
@misc{openvapt_p12,
author = {{OpenVAPT}},
title = {{P12: Firewall Policy Versus What Is Listening}},
year = {2026},
howpublished = {\url{https://openvapt.com/academy/p12.html}},
note = {OpenVAPT Academy, version 0.1.0-alpha.6. Accessed 16 October 2026}
}
Accessed: the date shown is today's date from your own browser (the site's build date without JavaScript); change it to the day you read the page.
Citing OpenVAPT does not mean OpenVAPT endorses, approves or has reviewed your work.