OPNexusdocs

Rule analysis

Under Policy › Rule analysis you ask which rule applies to a connection: source and destination IP, protocol, destination port and the ingress interface ("automatic" guesses it from the source IP and marks this as a note). With "Check egress side" the rules for outgoing traffic are checked as well. The first packet of a new connection is checked against the rule set actually loaded on the firewall; it is read-only. Per firewall a card appears with the verdict (Allowed, Blocked, Rejected), the certainty (certain, probable, unknown; tooltip with the reasons) and the deciding rule. If the result is "unknown" (for example the destination port is missing or an alias cannot be resolved), the card deliberately shows no verdict but the open points. Under "Why?" every checked rule is listed in evaluation order with ✓/✗/? per field. The query is in the address bar and can be shared as a link.

Cleanup#

The Cleanup tab (Policy › Rule analysis › Cleanup) lists per firewall the rules worth a look. You choose the firewall and the threshold (7, 30, 90 or 180 days); the selection is in the address bar (?tab=cleanup&host=…&days=…). The list itself is only read; changing goes through the selection (see below):

FindingMeaning
UnusedOPNexus has observed the rule for at least the threshold and has seen no hit during that time (see "Rule usage"). A new rule appears only after the observation period.
ShadowedAn earlier quick rule already matches everything this rule matches; the rule never decides. The shadowing rule is shown next to it.
DuplicateLike shadowed, but the earlier rule has the same action and matches exactly the same.
Disabled for a long timeThe rule is disabled and OPNexus has seen it unchanged for at least the threshold (from the change history).

Every finding carries a certainty. Certain exists only with complete, fresh evidence: for "unused" the rule must be loaded in pf, without a schedule, and the counters must be fresh; for "shadowed/duplicate" the order comes from the firewall, the shadowing rule is loaded and the comparison is based on the rules themselves. Probable means: it rests on an assumption (the content of aliases, an estimated order, a rule with a schedule, a missing pf rule set). Unknown means: there is a hint without evidence, for example because the rule is not loaded in pf or the counters are outdated. The tooltip explains each. What is not proven is never "certain".

The Action column says what selecting the rule would do (Disable or, for an already disabled rule, Delete) or why the rule is not offered: automatic rules (generated by OPNsense), rules in the legacy format (migrate in OPNsense first), rules deployed by OPNexus (you remove those through the normal flow of the rules page, otherwise OPNexus recreates them) and rules with the finding "unknown". The security posture links its findings "unused", "shadowed" and "duplicate" directly into this list. Via API: GET /api/hosts/{id}/rule-analysis/cleanup?unused_days=30, via MCP: rule_cleanup_candidates.

Management sources (prerequisite)#

Before the cleanup may change anything, you enter the management sources: the IP addresses or networks (CIDR, no host names) from which your firewalls are managed (OPNexus itself, your workstation, a jump host). Until then the tab shows a notice and (for administrators only) a small form; the same is under Settings › Rule cleanup, where you also find the limit per run (1 to 25, default 10) and the waiting time before deletion (1 to 365 days, default 7). For every selected rule OPNexus checks whether it can match a packet from a management source to an address of the firewall on a management port (API port from the host address, 443, 80, 22 and the further management ports that you enter under Settings › Rule cleanup, e.g. SSH on 2222 or the web interface on its own port; up to 20 ports). This is checked on every interface, also for packets over unassigned devices (WireGuard, OpenVPN, IPsec). If the rule matches or this cannot be ruled out, it is never disabled. In addition there are cluster rules (CARP, pfsync), which are never offered. Re-enabling a block rule that could hit management access requires explicit confirmation per rule.

OPNexus itself is protected automatically. For every firewall the cleanup asks when planning from which address the firewall sees OPNexus coming (its own API connection in the state table, via diagnostics/firewall/query_states), and additionally protects that address. The preview shows it per firewall ("additionally protected" or "already in the management sources"). If it cannot be determined (the API key lacks the privilege Diagnostics: States, or the firewall is attached to the management tunnel), the preview says so. Then enter the address yourself (with NAT the sender address after translation, via the management overlay the overlay address). If it is missing, a cleanup could disable exactly the rule through which OPNexus reaches the firewall; then the automatic reset fails as well. Under Settings › Rule cleanup OPNexus also suggests your browser's address (as OPNexus sees it; the firewalls may see it differently). A "savepoint" with reversal by the firewall itself does not exist in OPNsense 26.7 (checked in the source code and live: firewall/filter/savepoint answers 404); resetting remains OPNexus's job. Sources, ports and firewall addresses are visible only to administrators; everyone else only sees whether something is entered.

Disable, confirm, automatic reset#

  1. Select. Per run either only disable or only delete, at most as many rules as configured. For "probable" findings OPNexus asks before the preview, per rule with a fixed text, whether you have checked that the rule is not needed (schedule, alias content, short observation window, block rule without hits). "Unused" is at most "probable" under 30 days of observation and for block rules.
  2. Preview. OPNexus computes everything fresh from the firewall (in a cluster from all nodes; the rule must have the same UUID on every node and there must be exactly one master). Per rule the preview shows action, finding, certainty, the protection check for management access and notes (e.g. "changed externally"). The preview is valid for 5 minutes and belongs to whoever created it. Open maintenance, deployments or another cleanup in the cluster block it.
  3. Deploy (administrators only, with entry of the firewall name). OPNexus checks the state again and writes nothing if it deviates from the preview. Then the rules are disabled (in a cluster the backup first) and applied.
  4. Confirm or reset. The box at the top of the tab shows the countdown. Confirm (operator or administrator, only in a browser session, never via API token) reads every firewall once more beforehand and refuses if it does not respond: that is the signal that you may have locked yourself out. If you do not confirm in time, OPNexus resets automatically; with Reset now this happens immediately (administrator, or operator if this switch is allowed in the settings). If a rule failed or is unclear (status Partial), confirming is blocked. If the reset itself fails, Retry reset helps. After a reset the rule's observation window starts anew.

Deleting and restoring#

Only rules that are already disabled are deleted: a rule disabled and confirmed, after the waiting time (and only if it has been unchanged and not changed externally since) or a rule disabled by hand with the finding "disabled for a long time" (certain). A disabled rule is not loaded in the firewall, so deleting changes nothing there and therefore has no confirmation window. Beforehand OPNexus saves the complete rule content including position; without a backup nothing is deleted. Under Cleanup history (at the bottom of the tab) every row shows its steps; for deleted rules there is Restore (administrators only, with the firewall name): the rule comes back from the backup, disabled, with a new UUID (in a cluster on all nodes) and, if possible, directly before its former successor. If the position cannot be restored, the rule is placed at the end of its group and OPNexus points this out. If the firewall in the meantime lacks an alias or a category of the rule, it refuses and its message appears unchanged in the result. To switch it on there is Re-enable (also for rules disabled and confirmed): a separate run with a confirmation window, because switching on a block rule can lock you out.

Permissions at a glance: preview, cancel and confirm are allowed to operators and administrators; deploy, retry and restore only to administrators; read-only accounts see the list and the history but no buttons. Every step appears per rule in the audit log and in the rule's change history (origin "via OPNexus").

History of a rule#

Every 15 minutes OPNexus reads the rules of each firewall (two read accesses) and compares them with the last seen state – including rules that do not come from OPNexus. Every change becomes an event: created, changed (with before/after of the affected fields), moved (only order or group), enabled, disabled, removed. The origin is "via OPNexus" if the audit knows of a deployment or reset of this rule on this firewall since the previous observation (and not yet for any other change) (with the user), otherwise "external" (in the firewall's interface, by script or through another access). The first observation of a firewall only stores the initial state, no "created" events arise for existing rules; an empty or incomplete response from the firewall is discarded, and if more than half of the rules disappear at once, only the second identical observation counts; a change between two observations appears at the time of the second. Events are kept for 365 days.

The history is visible in the live view (Policy › Live across all hosts) via the row action History, in the cleanup list at the icon next to the rule, and via API (GET /api/hosts/{id}/live-rules/{uuid}/history). For a rule managed by OPNexus, the stored versions and the audit entries of the rule are shown as well. Automatic rules are not tracked.