Most network engineers will agree that keeping a firewall rulebase free of unnecessary rules is good practice. This involves finding candidates for removal based on traffic data captured in the firewall logs to identify which rules and objects were actually used.
With this data, it is possible to clean up rules and objects within the rules that are never hit, as well as remove object members that are not hit in any rule. The benefits of rule cleanup are not only for improving the maintainability, but also the performance of the firewall. In high-transaction systems, such as financial trading systems or e-commerce platforms, squeezing the most performance out of the firewall can become a crucial exercise. Once cleanup is completed, additional improvements in performance can be achieved by using the same traffic log data to determine the most used rules and objects. This forms the basis for re-ordering rules, where the objective is to move the most frequently used rules to the beginning of the rulebase as long as there is no impact on policy.
Re-ordering rules to improve performance requires rule dependencies to be taken into account so that the firewall’s behavior is not adversely impacted. Moving a rule will change the behavior if any of the rules passed over by the moved rule have a rule order dependency with it, i.e. they overlap with it and perform a different action. For example, moving an allow rule over an overlapping deny rule would cause some previously denied packets to now be allowed. You even need to take into account rule options such as logging or user authentication.
Often, only specific objects within the rule are frequently used and these specific portions might not have any rule order dependencies. In these cases it might be easier to simply carve out separate rules using these most-used objects and add them at the beginning of the rulebase.
To illustrate some of these points, consider the following example ruleset for a perimeter firewall connected to the Internet, a DMZ network hosting publicly accessible web servers, and an internal network hosting some application servers.
| Rule ID |
Source |
Destination |
Service |
Action |
Options |
| 1 |
Any |
WebServers |
WebSvcs |
Accept |
|
| 2 |
OrderWebServers |
AppServers |
AppSvcs |
Accept |
Log |
| 3 |
MgtNets |
Firewall |
MgtSvcs |
Accept |
Log |
| 4 |
Any |
Firewall |
Any |
Deny |
Log |
| 5 |
Any |
DataCenterSvrs
InventorySvrs
AppSvrs
PartnerSvrs |
DangerousSvcs |
Deny |
Log |
| … |
… |
… |
… |
… |
… |
| 60 |
InventoryAccessNets |
InventorySvrs |
InventorySvcs |
Accept |
Log, Auth users |
| … |
… |
… |
… |
… |
… |
| 100 |
InventoryPartnerNets |
PartnerSvrs |
PartnerSvcs |
Accept |
Log |
In this rulebase, rules 100 and 60 were the two most used rules, in that order. Determining whether or not these rules overlap requires identifying the specific IP addresses and subnets used in each of the network groups and the services included in the service groups. If the service groups DangerousSvcs and InventorySvcs contain any of the same services, then rule 60 cannot be moved up in the rulebase any further than rule 5 because both rules refer to the network group InventorySvrs and they have differing actions. Similarly, rule 100 cannot be moved in front of the rule 60 if they overlap since rule 60 has a user authentication option even though they have the same rule action. It might be better to redefine rule 100 to exclude the addresses and services referred to by rule 60 so that rule 100 can be moved higher up in the rulebase.
It is possible to determine the most used rules or most used addresses and services in the firewalls with the help of scripts. The log data can be parsed and stored in a database and SQL queries used to count the number of rows for each rule ID to get the rule usage. However, determining rule order dependencies does require examining the relationships between each rule and every other rule in the rulebase. You need to determine the effective portion of each rule, taking into account the content of each object used in the rule before you even try to determine the overlaps between the rules. Correlating these addresses or services to the object groups requires an understanding of object and rule structures within the firewall configuration. Performing this analysis manually requires a lot of time and is error prone because of the large number of rule and object combinations that have to be looked at. If the rulebase is non-trivial, even a scripting solution is untenable.
Fortunately, Athena FirePAC automates this process and generates a report that identifies all structural redundancies in rules and objects that can be cleaned up, all unused objects and rules that can be cleaned up using the firewall log data, and provides an optimized rule order where the rules are reordered based on most used rules and rule order dependencies.