15. Firewall rules
Starting with DynFi Manager version 24.0, it is possible to view the rules of each connected firewall. The rule list is available for each device - choose “Rules” in device menu.
Rules are presented separately for each interface, with floating rules grouped in their own section. For each interface, it’s also possible to show or hide:
Floating rules which affect this interface,
Internal rules generated by the firewall or its plugins which affect this interface.
Some rule attributes are presented as icons to save space. Each icon (and some non-icon attributes) has a tooltip explaining its meaning. For alias-based rules, it is possible to check the source or destination alias without leaving the rule list. To see the alias details click on the alias icon. State details (traffic data such as packets or bytes sent) are displayed in a tooltip on hover. Please note that this live data can only be displayed if DFM is connected to the given device.
If an interface is disabled on the firewall, it is marked as (disabled) in the interface selector, and a warning above the list reminds you that the rules of this interface are not active.
For a detailed explanation of each rule attribute, please consult your firewall documentation.
15.1. Managing rules directly from DynFi Manager
Starting with DynFi Manager version 26.0, it is possible to manage the rules of a connected firewall directly from the DynFi Manager interface, without needing to access the firewall’s own administration panel. This feature works in a way similar to the existing “Restrict rules” mode and provides full control over rule ordering and configuration.
15.1.1. Entering Edit rules mode
On the Rules list page, click the Edit rules button at the bottom of the page to enter Edit rules mode. The page header turns red to clearly indicate that you are now in an active editing session, and an Apply changes and a Cancel button appear at the bottom of the page.
While in Edit rules mode, an Operations column with a set of action buttons appears on the right-hand side of each rule row. Outside Edit rules mode this column is hidden.
“Edit rules” mode
15.1.2. Selecting rules and reordering them
You can select one or more rules by clicking anywhere on their rows. Selected rows are highlighted. Once one or more rules are selected, use the arrow buttons on any rule row to reorder:
Arrow up (↑) — moves all selected rules above the rule whose arrow up button was clicked.
Arrow down (↓) — moves all selected rules below the rule whose arrow down button was clicked.
This allows you to precisely position a group of rules relative to any other rule in the list without dragging and dropping.
15.1.3. Editing a rule
Click the edit button (pencil icon, the first button below the arrow buttons) on a rule row to open the Modify rule modal window. The modal contains a form similar to the one available in the firewall’s own administration panel. It allows editing e.g.:
Action — the rule action (e.g. Pass, Block, Reject).
Disabled — check Disable this rule to disable the rule without deleting it.
Interface — the interface to which this rule applies.
TCP/IP Version — IPv4, IPv6, or both.
Protocol — the protocol to match (e.g. TCP, UDP, ICMP).
Source — source type and optional invert match, plus a port range (from / to).
Destination — destination type and optional invert match, plus a port range (from / to).
Log — optionally log packets handled by this rule.
The configuration covers all basic rule settings of each supported firewall and some advanced settings. Interfaces disabled on the firewall are marked as (disabled) in the interface lists.
The rule is validated when you confirm the form. DynFi Manager checks that the fields are consistent with each other (e.g. a port can only be set for a protocol that uses ports, an ICMP type only for ICMP, and a gateway must match the rule’s address family) and that the rule only references objects which exist on the firewall (aliases, interfaces, gateways, schedules, categories). If there are problems, they are listed in the modal window and the rule cannot be saved until they are fixed. When an existing rule is edited, only the fields you changed (and the fields depending on them) are checked, so a problem the rule already had on the firewall does not prevent you from changing an unrelated field.
After making your changes, click Modify rule to confirm them. The modal closes and the updated rule is reflected immediately in the list. The change is not yet sent to the firewall — it is accumulated along with any other pending changes in the current editing session.
For a full explanation of rule attributes and firewall-specific behaviour, consult your firewall’s documentation.
Edit modal
15.1.4. Adding a rule
Click the Add rule button at the bottom of the page to open Add rule modal window. The form is the same as in the case of editing a rule. New rule is added at the end of the rule list.
15.1.5. Cloning a rule
Click the clone button (the button immediately after the edit button) on a rule row to clone a rule. The cloned rule is added at the end of the rule list.
15.1.6. Disabling a rule
Click the disable button (the button immediately below the edit button) on a rule row to toggle the disabled state of that rule. Disabled rules are visually distinguished in the list (indicated by the color of pass/block/reject icon on on the left side of the rules row, consistent with how the firewall itself marks disabled rules). Disabling a rule is a non-destructive operation — the rule remains in the list and can be re-enabled at any time within the same or a future editing session.
15.1.7. Deleting a rule
Click the delete button (the last button in the action group, represented by a trash/remove icon) on a rule row to remove the rule from the list. The deletion is staged and will only take effect on the firewall once changes are applied.
Note
Deleting a rule cannot be undone within the current editing session. If you delete a rule by mistake, click Cancel to discard all pending changes and restore the rules to their last saved state.
15.1.8. Applying or cancelling changes
All modifications made during an Edit rules session - reordering, edits, disables, and deletions - are accumulated locally and are not sent to the firewall until you explicitly confirm them.
Apply changes sends all accumulated changes to the firewall. The button stays disabled until at least one change has been made. Before anything is sent, DynFi Manager validates the rules affected by the changes once more; if any of them is invalid, nothing is sent and an error message lists the invalid rules. After the changes are applied, DynFi Manager reloads the rule list from the firewall to reflect the current state.
Each applied set of changes is recorded as a rules update. Its progress and result, including the list of requested changes, can be checked under Rules > Updates in the main menu (see Rules updates).
Cancel discards all pending changes and exits Edit rules mode, returning the rule list to its previous state.
Note
Reloading the rules from the firewall after applying changes ensures that the DynFi Manager view is always consistent with the actual firewall configuration, including any ordering or normalisation that the firewall may apply to rules internally. While the reload is in progress, all editing and management actions (including Edit rules, Restrict rules, and Check for new rules) are temporarily disabled.
15.1.9. Permissions
To enter Edit rules mode and apply changes - add, clone, reorder, modify, disable and delete rules - a user needs all of the following permissions:
WriteandRead restricted rulesfor Firewall rules,
Createfor Configs,
Readfor Devices.
Users without these permissions will not see the Edit rules button on the Rules list page.
15.2. Rule collections
Starting with DynFi Manager version 27.0, it is possible to define sets of firewall rules once in DynFi Manager and push them to many firewalls. Such a set is called a Rule collection. The concept is similar to Alias Collections (see Managing aliases with DFM): instead of adding the same rules to each firewall by hand, you maintain them in one place and synchronize them with the selected devices whenever they change.
A rule collection:
has a unique name (names are compared case-insensitively),
is built for one target distro - OPNsense or pfSense - because the rule model differs between the two. A collection can only be synchronized with devices running its target distro,
lives in DynFi Manager only and is not bound to any device. Its rules are pushed to the firewalls only when you synchronize the collection.
Because a collection is not bound to any device, its rules don’t contain anything which depends on a particular firewall:
Interface - a collection’s rules have no interface. The interface is chosen separately for each device when the collection is synchronized, and all the rules of the collection are placed on that one interface. This is because interface names differ from one firewall to another.
Floating rules - a collection contains interface rules only; floating rules are not supported.
Schedule and Gateway - these fields cannot be set in a collection rule, as schedules and gateways are defined separately on each firewall. If needed, set them on the device after the synchronization.
Aliases - aliases cannot be selected as a rule’s source or destination. A source or destination can be any, a single host or network, or one of the standard networks offered by the target distro (e.g. This Firewall).
Rule collections are available in the main menu under Rules > Collections. Like the Aliases menu, the Rules menu is only shown to users assigned to at least one device group.
15.2.1. Rule collections library
The Rule collections page lists all rule collections, with their name, target distro and creation date. The list can be searched by name and sorted. Click a collection’s name (or the information icon next to it) to open it in the editor. When you hover over a collection’s row, the following buttons appear on its right-hand side:
Synchronize - synchronizes the collection with selected devices (see Synchronizing a rule collection),
Clone - creates a copy of the collection (see Cloning a rule collection),
Delete - deletes the collection, after a confirmation.
Deleting a collection does not affect the firewalls it was synchronized with - the rules which were pushed to them remain there.
Rule collections library
15.2.2. Creating a rule collection
Click Create new collection at the bottom of the Rule collections page. In the modal window, enter the collection’s name, choose its target distro (OPNsense or pfSense) and confirm. The new, empty collection opens in the editor.
The target distro decides which rule fields and values are available in the collection’s rules, so choose the distro of the devices you intend to synchronize the collection with.
Creating a rule collection
15.2.3. Editing a rule collection
The rule collection editor shows the collection’s name and target distro in the header, and its rules below. Editing the rules works the same way as editing the rules of a device in Edit rules mode (see Managing rules directly from DynFi Manager):
click rows to select one or more rules, and use the arrow up / arrow down buttons of another rule to move the selected rules above or below it,
use the edit, clone, disable and delete buttons in a rule’s row to modify, duplicate, disable or remove that rule,
click Add rule to add a new rule at the end of the collection.
Rule collection editor
The Add rule / Modify rule modal window is the same as for device rules, except for the fields which cannot be set in a collection (see Rule collections): instead of the interface selector, a note explains that the interface is chosen per device during synchronization, and the Schedule and Gateway fields are disabled. Rules are validated in the same way as device rules, as far as it is possible without a device - e.g. whether a referenced alias or interface exists can only be checked when the collection is synchronized with a particular firewall.
Changes are accumulated in the editor until you click Apply changes, which saves the collection. The button stays disabled until at least one change has been made. The Synchronize button opens the synchronization wizard for this collection; it is only enabled when there are no unsaved changes, so that the collection is always synchronized in its saved state. Back to rule collections returns to the library.
Note
Saving a collection does not change anything on the firewalls. To push the new version of the rules to the devices, synchronize the collection again.
Editing a rule of a collection
15.2.4. Cloning a rule collection
Click Clone next to a collection in the library to create its copy. In the modal window, enter the name of the new collection (by default the original name followed by (copy)) and choose its target distro. The new collection opens in the editor.
The target distro of the copy can differ from the original one, which is a convenient way to build e.g. a pfSense version of an OPNsense collection. In such a case a warning reminds you that some rules may be incompatible with the new distro - review them in the editor before synchronizing the copy.
The rules of the copy get new identifiers. For DynFi Manager, they are therefore different rules than the rules of the original collection: synchronizing the copy with a device to which the original collection has already been synchronized adds new rules rather than updating the existing ones (see How rules are matched).
Cloning a rule collection with a different target distro
15.2.5. Synchronizing a rule collection
Synchronization pushes the rules of a collection to one or more firewalls. To start it, click Synchronize next to the collection in the library, or in the footer of the collection editor. A wizard opens, with two or three steps.
Step 1 - devices. Select the devices to synchronize the collection with. The table can be searched, sorted and paged, and lists only the devices running the collection’s target distro. The devices with which the collection was synchronized before are preselected. Click Next: assign interfaces.
Synchronization wizard - selecting devices
Step 2 - interfaces. For each selected device, choose the interface on which the collection’s rules will be placed. The interfaces are read from each device, so the device must be reachable; if no interfaces can be obtained for a device, a warning is displayed in its row and the device is skipped, while the other devices can still be synchronized. The interface chosen for a device during the previous synchronization is preselected and marked with a star (★). Interfaces disabled on the firewall are marked as (disabled). Use the × button to remove a device from the synchronization, or Back: change devices to return to the previous step.
In the same step, choose the Placement of new rules:
At the bottom (default) - new rules are added after the existing rules of the interface,
At the top (evaluated first) - new rules are added before the existing rules of the interface,
After a specific rule (choose per firewall) - the position is chosen separately for each firewall in an additional step.
Placement only applies to rules which are not yet present on the firewall. Rules which are already there (because they were pushed by an earlier synchronization of the same collection) are updated in place and keep their position.
Optionally, switch on Expert mode to change the synchronization settings (see Synchronization settings).
Synchronization wizard - assigning interfaces
Step 3 - placement (only when After a specific rule was chosen). For each firewall, the existing rules of the selected interface are displayed. Either choose Before all <interface> rules (top), or select the rule after which the collection’s new rules should be inserted. If the interface has no rules yet, the new rules are simply added to it and nothing needs to be chosen. Use Back: change interfaces to return to the previous step.
Synchronization wizard - choosing where to insert new rules
Click Synchronize to start the synchronization. First, DynFi Manager validates the collection’s rules (with the interface chosen for each device) against the most recent config backup of each selected device - e.g. it checks that the chosen interface exists on the device. If any rule is invalid for any of the devices, the synchronization is not started at all and an error message is displayed. Otherwise DynFi Manager:
creates a separate rules update for each device; the updates are independent of each other and can succeed or fail independently (just like Alias synchronizations),
rejects the update of a device which can’t be updated because firewall updates are disabled globally or for the device,
redirects you to the details of the update (if one device was selected) or of the whole request (if several devices were selected), where the progress can be followed (see Rules updates).
The update of each device is “all or nothing”: either all the changes resulting from the synchronization are applied, or - if a problem is detected, e.g. a conflict reported according to the synchronization settings - the update is marked as Not applicable and the rules of the device are not modified at all.
Note
Synchronization uses the collection as it is at the moment of starting the synchronization. Changes made to the collection afterwards are not propagated to the devices automatically - synchronize the collection again to push them.
15.2.6. How rules are matched
Every rule of a collection has a unique identifier (on OPNsense the rule’s UUID, on pfSense its tracker number). When a rule is pushed to a firewall, it keeps that identifier. During the next synchronization, DynFi Manager compares the identifiers of the collection’s rules with the identifiers of the rules on the device to decide which rules are:
present only in the collection - typically new rules, which haven’t been synchronized with this device yet,
present only on the device - rules which don’t come from the collection (only the non-floating rules of the interface selected for the device are considered; rules of other interfaces and floating rules are never affected),
present in both - rules which were pushed by an earlier synchronization of this collection.
Rules are matched by their identifiers only, not by their content. A rule on the device which happens to have the same settings as a collection rule, but was not created by synchronizing this collection, is treated as a different rule.
15.2.7. Synchronization settings
By default, the synchronization:
creates the rules which are present in the collection but not on the device,
does not touch the rules which are present on the device but not in the collection,
replaces the rules which are present in both with the version from the collection - any change made to such a rule directly on the device is overwritten.
These settings can be changed after switching on Expert mode in the second step of the wizard:
When rule is present only in collection
Create rule (default) - the rule is added to the device, at the position chosen in Placement of new rules.
Skip this rule (do nothing) - the rule is not added.
Report error - the synchronization is stopped and the update is marked as Not applicable. This can be useful to make sure that the device already contains all the rules of the collection.
When rule is present only in device
Skip this rule (do nothing) (default) - the rule is left as it is.
Delete rule - the rule is deleted from the device. While this option is selected, a warning reminds you that all rules of the selected interface which are not in the collection will be deleted; rules of other interfaces and floating rules are not affected.
Report error - the synchronization is stopped and the update is marked as Not applicable. This can be useful to make sure that the interface contains no rules other than those of the collection.
When rule is present in both
Save the rule from the collection (default) - the rule on the device is replaced with the one from the collection.
Skip this rule (do nothing) - the rule on the device is left as it is.
Report error - the synchronization is stopped and the update is marked as Not applicable.
The settings used are shown afterwards in the details of the rules update.
Warning
Delete rule combined with a collection synchronized with a busy interface removes every rule of that interface which does not come from the collection. Make sure this is the intended result before starting the synchronization.
Synchronization settings in expert mode
15.2.8. Rule collections permissions
Access to rule collections is controlled by the Rule collections permissions:
Read- allows a user to view the rule collections library and the collections,Create- allows a user to create new collections and clone existing ones,Write- allows a user to modify collections,Delete- allows a user to delete collections,Synchronize- allows a user to synchronize collections with devices. Since a synchronization reads and modifies the rules of the devices, it additionally requires theRead,WriteandRead restricted rulespermissions for Firewall rules, and theReadpermission for Devices.
A collection can only be synchronized with devices belonging to the user’s device groups.
15.3. Rules updates
Every change of a firewall’s rules made by DynFi Manager is recorded as a rules update. Rules updates are created when:
changes made in Edit rules mode on a device’s rules list are applied (see Managing rules directly from DynFi Manager),
a rule collection is synchronized with devices (see Synchronizing a rule collection) - one update per device.
Rules updates are listed in the main menu under Rules > Updates (in earlier versions, this list was available as Firewall operations > Rules updates). Updates which were requested together - e.g. the updates resulting from synchronizing one collection with several devices - are grouped in a request, whose details show the status of each device’s update.
The status of an update can be, among others:
Requested, Started - the update is waiting or in progress,
Success - the changes were applied to the firewall,
Failed - the update could not be completed; the reason is shown in the update’s details,
Not applicable - the changes could not be applied to the current rules of the device, e.g. because of a conflict reported according to the synchronization settings; the rules of the device were not modified,
Device not reachable - DynFi Manager could not connect to the device,
Rejected - the update was not started at all, because firewall updates are disabled globally or for the device, or because the system version of the device does not support rules updates.
List of rules updates
15.3.1. Rules update details
The details page of a rules update shows the device in its header and a summary on top: when and by whom the update was requested, when it started and finished, its status and, for a rejected update, the reason of the rejection. The rest of the page depends on the origin of the update:
Synchronization of a rule collection (Rules synchronization details) - the rules of the synchronized collection, as they were at the moment of synchronization, are shown on the left. On the right, the synchronization settings used (including the placement of new rules) and the problems encountered, if any, are listed. Rules which caused a conflict are highlighted.
Changes made in Edit rules mode (Rules update details) - the list of requested changes (add, modify, delete, reorder) is shown as rows of a rules table: the operation on the left, and the rule it was applied to in the remaining columns. A change which failed is marked in red.
Details of a rules synchronization
Details of a rules update made in Edit rules mode
Viewing rules updates requires the Read permission for Rules updates. Opening the details of an update also
requires the Read permission for Devices.
15.4. Limiting access to the rules
In some cases it may be desirable to hide certain firewall rules from a group of DynFi Manager users. There are five permissions which affect rules:
Create- allows a user to download new rules from the firewall (“Check for new rules”),
Read- allows a user to view non-restricted rules,
Write- allows a user to add and modify rules in Edit rules mode (see Permissions for the full set of permissions required),
Read restricted rules- allows a user to view all rules,
Restrict rules- allows a user to restrict the visibility of rules.
To hide a set of rules from a group of users, first create a role with the “Read” permission for rules (and none of the other rule permissions) and assign this role to the selected users. Then, on the Rules list, use the “Restrict rules” button to enter admin mode and select the rules to hide. You can select rules for multiple interfaces before confirming the selection. The rules which have already been hidden are preselected.
Please note that the “Restrict rules” button is only visible to administrator and users with the “Restrict rules” permission.
“Restrict rules” mode
Once you confirm your selection, the rules are restricted. Administrator and users with the “Read restricted rules” permission can see restricted rules, which are marked with a red padlock icon. All users with only “Read” permission will not see these rules at all.
Admin view of restricted rules
Note
Due to technical constraints, it’s not possible to manage restrictions of OPNsense rules generated automatically by the firewall. Such rules are restricted by default and cannot be unrestricted manually. This constraint also affects OPNsense legacy rules which don’t have a UUID.