Firewall and NAT
Requires OPNsense Firmware >= 26.1.1
- async OPNsenseClient.get_firewall()
Return firewall filter rules and all supported NAT rule groups.
- Returns:
- Mapping with top-level
rulesfor firewall filter rules, excluding lockout and automatically generated firewall rules, and
natgroups for destination NAT, one-to-one NAT, source NAT, and NPT rules. Rule groups are keyed by rule UUID. Each group is independent: a group whose endpoint is missing (404) is empty. Withthrow_errorsoff, a group isNone, meaning unknown, when its endpoint is forbidden (403), fails, or returns a malformed body. Withthrow_errorson, those request failures raise instead.
- Mapping with top-level
- Return type:
- async OPNsenseClient.toggle_firewall_rule(uuid, toggle_on_off=None)
Toggle a Firewall Rule on or off and apply the filter.
- Parameters:
- Returns:
- True when the Router acknowledged the save and confirmed
the apply. False when the save was not acknowledged (no apply is sent), the apply was not confirmed, or an error was suppressed. With
throw_errorsenabled, an invalidtoggle_on_offraisesOPNsenseInvalidArgumentand transport errors raiseOPNsenseError.
- Return type:
- async OPNsenseClient.toggle_nat_rule(nat_rule_type, uuid, toggle_on_off=None)
Toggle a NAT rule on or off and apply the NAT changes.
- Parameters:
- Returns:
- True when the Router acknowledged the save and confirmed
the apply. False when the save was not acknowledged (no apply is sent), the apply was not confirmed, or an error was suppressed. With
throw_errorsenabled, an invalidtoggle_on_offraisesOPNsenseInvalidArgumentand transport errors raiseOPNsenseError.
- Return type:
- async OPNsenseClient.kill_states(ip_addr)
Kill the active states of the IP address.
- async OPNsenseClient.toggle_alias(alias, toggle_on_off=None)
Toggle an alias on or off, commit it and reconfigure the aliases.
- Parameters:
- Returns:
- True when the Router acknowledged the toggle and the
commit and confirmed the reconfigure. False when the alias cannot be found, a save step was not acknowledged (nothing further is sent), the reconfigure was not confirmed, or an error was suppressed. With
throw_errorsenabled, an invalidtoggle_on_offraisesOPNsenseInvalidArgumentand transport errors raiseOPNsenseError.
- Return type: