iptables · nftables · Cisco ASA · PAN-OS · FortiGate · pfSense

Firewall Rule Analyzer

Load a firewall configuration to find rules that never match, rules that repeat an earlier one, rules that overlap with opposite actions, objects nothing uses, and permits from any source to administration and file-sharing ports. Ask whether one packet would pass and see which rule decides it.

Configuration

Drop a configuration file

Up to 12 MB of text

Configurations can reveal your network layout. They are read in this tab only. Address-translation (NAT) rules are not modelled; unsupported lines are listed, not skipped silently.

Load a configuration or press an example, then analyse it.

Firewall Rule Analyzer

Operator: Abdulla Al Fahad. How tools are built and checked

A rule set that has grown for years usually hides rules that do nothing: an allow placed under a broader deny, a second copy of a permit, an object group nobody references. None of them shows up in a normal review, because each rule looks reasonable on its own line. This page reads the whole configuration, turns every rule into the set of packets it matches, and reports the rules whose packets are already decided somewhere above them.

It reads iptables-save and ip6tables-save, nftables (the text of nft list ruleset and the JSON of nft -j), a Cisco ASA running-config, PAN-OS XML, a FortiGate configuration and a pfSense or OPNsense config.xml. The findings follow the anomaly types Al-Shaer and Hamed described for firewall policies in 2004: shadowing, redundancy, correlation and generalisation.

The wording of every finding is a statement about rule order and overlap, such as "INPUT #4 would deny packets, but INPUT #3 comes earlier and decides every packet it could match". The page never calls a configuration secure or insecure; the review priority only orders what to read first.

Key features

  • Shadowed rules: a rule whose every packet is decided earlier, by one rule or by several together, with the opposite action
  • Redundant rules: covered by earlier rules with the same action, and rules that a later rule with the same action makes unnecessary
  • Correlated rules (partial overlap with opposite actions) and generalisations, where a broader later rule contains an earlier exception
  • Permits from any source to SSH, Telnet, RDP, VNC, WinRM, FTP, SMB, NFS, rpcbind and common database ports, and any-source permits of every TCP port or of everything
  • Disabled rules, rules without logging or comments, rules with zero hits when the file carries counters, and unused, duplicate or empty objects
  • A packet query: protocol, source, destination, ports and interfaces go in, the deciding rule and the chains it passed through come out

What is compared and what is left out

Every rule becomes a union of boxes over seven dimensions: protocol, source address, destination address, source port, destination port, in-interface or zone, and out-interface or zone. Addresses of both families share one 129-bit number line, so an IPv6 prefix and an IPv4 prefix are intervals of the same kind. Negated matches are complements within their dimension.

Chains are followed the way each vendor evaluates them. iptables and nftables jump into user chains, RETURN goes back to the caller and the base chain policy decides what is left. An ASA access list ends in an implicit deny. PAN-OS ends with the built-in intrazone allow and interzone deny, which the page names when a query lands there. A FortiGate policy table and each pfSense interface list drop to a default deny.

iptables rules that match only established or related connections (a conntrack state list without NEW) cannot decide the first packet of a new connection, so they are left out of the analysis and counted in the notes. NAT tables are not modelled at all.

How it works

For each entry list the page walks the rules in order with a set of packets still undecided. A rule that takes none of them is unreachable; its packets are then attributed to the earlier rules that took them, preferring one rule that covers it completely and otherwise the smallest set that does. If all of those rules share the rule's action it is called redundant, otherwise shadowed.

Pairs of rules are compared separately for correlation, generalisation and redundancy by a later rule. A rule with a condition the page cannot model (an ICMP type, a rate limit, an application filter, a schedule) is treated as matching more than it really does, so it can be reported as covered but is never used to cover another rule. Those rules are listed.

The packet query runs the same walk with a single packet as the starting set. Parts of the walk that touch a rule with unmodelled conditions are returned as notes, because that rule might also match.

When this helps

  • Before decommissioning a legacy gateway, an engineer loads its ASA configuration and finds one object group with no members, three network objects that no rule references and two objects with identical content, so the migration plan starts with three objects to drop and two to merge.
  • After an audit asks why tcp/3389 reaches the DMZ, a query for an outside address to 10.1.1.50 port 3389 shows the exact permit that decides it and that a later deny is shadowed by it.
  • A team merging two iptables files runs both through the page and compares the redundant and shadowed lists; every rule in the second file that the first already decides is dropped before the merge.

Opening a file

  1. Paste the configuration or drop the file. The format is detected, and you can set it by hand, which matters for ip6tables output that has no address to give it away.
  2. Press Analyse rules. Large files are read in this tab and parsed in one pass.
  3. Read the findings from the top. Each names the rules involved, what the earlier rules decide, and a suggested edit.
  4. Open Packet query, choose the chain or access list, enter the packet and press Check packet to see the deciding rule.
  5. Download the PDF report, the XLSX workbook (findings, clean-up list, every rule, objects, unsupported lines) or the findings CSV.

Example

The Example iptables button: a web and database host with 15 INPUT rules and a WEB user chain

INPUT accepts ssh from 10.0.0.0/8 (rule 3), then drops ssh from 10.1.0.0/16 (rule 4) and accepts 10.0.0.0/8 again (rule 5); rule 7 accepts tcp/3306 from anywhere and rule 8 drops it from 192.168.0.0/16; rule 6 jumps to WEB, whose rule 4 accepts tcp/443 after rule 3 already returned it.

Findings for the 20 rules

12 findings: 4 high, 2 medium, 5 low and 1 informational. INPUT #4 and #8 and WEB #2 are shadowed, INPUT #5 is redundant to #3, INPUT #11 is redundant to the later #12, INPUT #7 allows any source to tcp/3306 (MySQL), WEB #4 and #5 are never reached, and INPUT #9 and #10 overlap with opposite actions. A query for tcp 172.16.5.9 to port 8600 is allowed by INPUT #9, not denied by #10.

Tips for best results

  • Select the iptables family by hand when the file is IPv6 and rules carry no address: an unspecified address then means any IPv6 address, not any IPv4 address.
  • Run an ASA show access-list capture as well as the running-config: hit counts appear in the file as (hitcnt=N), and the zero-hit finding only appears when at least one counter is present.
  • When a PAN-OS finding says a rule is covered "whatever the unmodelled conditions are", the cover is real; the opposite, a missing finding, proves nothing for rules that name applications.

Limits

Zero hits only counts packets since the counters were last cleared, and a yearly job leaves months of zero. Treat the finding as a question for the rule's owner.

Rules that carry conditions the page does not model are marked in the Rules tab and in Limits and notes, and are never used to cover another rule. A clean report on such rules means less than a clean report on plain ones.

Several base chains on one nftables hook, floating pfSense rules and PAN-OS rules in different zone pairs run in an order that spans lists. Each list is analysed on its own, so overlap between lists is not reported.

Common errors and how to fix them

The format was not recognised
The first lines carry no sign of a supported format. Choose the format in the list; for nft JSON the file must start with an object holding an nftables array.
No rules were found in this iptables input
Only the filter table is analysed. A file that holds just nat or mangle rules produces this message together with a note naming the tables that were left out.

Best practices

  • Fix shadowed rules before redundant ones. A shadowed allow is a rule that someone expects to work and does not, while a redundant rule only adds clutter.
  • Remove one finding at a time and re-run: deleting a redundant rule can turn the rule that covered it into the only one that decides those packets, and a duplicate that looked harmless changes the other findings.

What the review priority means

High marks findings where a rule does not do what its action suggests (shadowing) or where a permit names any source and an administrative, file-sharing or database port. Medium covers correlated rules and rules that are never reached, low covers redundancy, logging, comments and unused objects, and information holds disabled rules and generalisations.

The order is a reading order. A configuration with no findings has passed the checks this page makes and nothing else: it has not been tested against a policy, against NAT, or against the traffic that really crosses it.

Frequently asked questions

Does it understand NAT?

No. Rules are compared on the addresses they are written with, so a rule that matches a translated address, or a packet that NAT changes before the filter sees it, is outside the analysis. The notes list NAT tables and unsupported lines whenever they appear.

Why is a rule reported as shadowed by two rules instead of one?

Together the two cover all of its packets. The page first looks for a single earlier rule that covers the whole rule, and only then for the smallest group; the finding names every rule in that group, in file order.

How are rules from the paper's categories mapped?

Shadowed and redundant follow the definitions of Al-Shaer and Hamed, extended from single rules to groups of earlier rules. Correlation needs partial overlap with opposite actions, generalisation an earlier rule inside a later broader one with the opposite action, and a broad final deny-all is not reported as a generalisation because every rule set has one.