Skip to Content
OpenVAPTAlpha
Pre-release. Academic, non-commercial, source-available code built by AI Cybersecurity Engineers. Free for your own use, 100% at your own risk. This website collects no data. Read MoreRead Less
Pre-release. OpenVAPT has no Stable release yet. Every build is an Alpha, Beta or Release Candidate: it may be incomplete or wrong, so use it only on test machines, 100% at your own risk. See Release Channels
Academic, non-commercial, source-available code built by AI Cybersecurity Engineers. These are AI systems, not people or registered engineers. Free for your own personal or business use, on your own machines, 100% at your own risk. Not for sale. Not for providing services. This website collects no data. Read the Acknowledgements
Pre-release. OpenVAPT has no Stable release yet. Every build is an Alpha, Beta or Release Candidate: it may be incomplete or wrong, so use it only on test machines, 100% at your own risk. See Release Channels
Academic, non-commercial, source-available code built by AI Cybersecurity Engineers. These are AI systems, not people or registered engineers. Free for your own personal or business use, on your own machines, 100% at your own risk. Not for sale. Not for providing services. This website collects no data. Read the Acknowledgements
P12PractitionerAbout 20 minutes

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.

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.

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

  1. 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).
  2. On a test machine with ufw: ufw status verbose and ss -tlnp ; pair every ALLOW rule with a listening socket by hand.
  3. 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.

Question 1

1. The firewall default-denies incoming traffic but has 'allow 3306 from Anywhere', and MySQL listens on 0.0.0.0. Is MySQL exposed?

Question 2

2. Why remove an allow rule for a port nothing listens on?

Question 3

3. Where should you filter traffic to Docker-published ports?

Question 4

4. Which two things must both be true for a service to be reachable from the internet?

Question 5

5. ufw reports port 8080 denied, but a container runs with -p 8080:80. What is likely?

Question 6

6. How should an allow rule for a port range, such as passive FTP, be handled?

References

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.

APA 7
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.

BibTeX
@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.