Firewall — Firewall Rule Best Practices (2024)

This section covers general best practices for firewall rule configuration.

Default Deny

There are two basic philosophies in computer security related to access control:default allow and default deny. A default deny strategy for firewall rules isthe best practice. Firewall administrators should configure rules to permit onlythe bare minimum required traffic for the needs of a network, and let theremaining traffic drop with the default deny rule built into pfSense® software.In following this methodology, the number of deny rules in a ruleset will beminimal. They still have a place for some uses, but will be minimized in mostenvironments by following a default deny strategy.

In a default two-interface LAN and WAN configuration, pfSense software utilizesdefault deny on the WAN and default allow on the LAN. Everything inbound fromthe Internet is denied, and everything out to the Internet from the LAN ispermitted. All home grade routers use this methodology, as do all similar opensource projects and most similar commercial offerings. It’s what most peopleexpect out of the box, therefore it is the default configuration. That said,while it is a convenient way to start, it is not the recommended means oflong-term operation.

pfSense software users often ask “What bad things should I block?” but that isthe wrong question as it applies to a default allow methodology. Noted securityprofessional Marcus Ranum includes default permit in his “Six Dumbest Ideas inComputer Security” paper, which is recommended reading for any securityprofessional. Permit only what a network requires and avoid leaving the defaultallow all rule on the LAN and adding block rules for “bad things” above thepermit rule.

Keep it short

The shorter a ruleset, the easier it is to manage. Long rulesets are difficultto work with, increase the chances of human error, tend to become overlypermissive, and are significantly more difficult to audit. Utilize aliases tokeep the ruleset as short as possible.

Review Firewall Rules

The best practice is a manual review of the firewall rules and NAT configurationon a periodic basis to ensure they still match the minimum requirements of thecurrent network environment. The recommended frequency of such reviews variesfrom one environment to another. In networks that do not change frequently, witha small number of firewall administrators and good change control procedures,quarterly or semi-annually is usually adequate. For fast changing environmentsor those with poor change control and several people with firewall access,review the configuration at least on a monthly basis.

Quite often when reviewing rules with customers, Netgate TAC asks about specificrules and they respond with “We removed that server six months ago.” Ifsomething else would have taken over the same internal IP address as theprevious server, then traffic would have been allowed to the new server that maynot have been intended.

Document The Configuration

In all but the smallest networks, it can be hard to recall what is configuredwhere and why. The best practice is to use the Description field in firewalland NAT rules to document the purpose of the rules. In larger or more complexdeployments, create and maintain a more detailed configuration documentdescribing the entire pfSense software configuration. When reviewing thefirewall configuration in the future, this will help determine which rules arenecessary and why they are there. This also applies to any other area of theconfiguration.

It is also important to keep this document up to date. When performing periodicconfiguration reviews, also review this document to ensure it remains up-to-datewith the current configuration. Ensure this document is updated wheneverconfiguration changes are made.

Reducing Log Noise

By default, pfSense software logs packets blocked by the default deny rule. Thismeans all of the noise getting blocked from the Internet will be logged.Sometimes there will not be much noise in the logs, but in many environmentsthere will inevitably be something incessantly spamming the logs.

On networks using large broadcast domains – a practice commonly employed bycable ISPs – this is most often NetBIOS broadcasts from clue-deficientindividuals who connect Windows machines directly to their broadbandconnections. These machines will constantly pump out broadcast requests fornetwork browsing, among other things. ISP routing protocol packets may also bevisible, or router redundancy protocols such as VRRP or HSRP. In co-locationenvironments such as data centers, a combination of all of those things may bepresent.

Because there is no value in knowing that the firewall blocked 14 millionNetBIOS broadcasts in the past day, and that noise could be covering up logsthat are important, it is a good idea to add a block rule on the WAN interfacefor repeated noise traffic. By adding a block rule without logging enabled onthe WAN interface, this traffic will still be blocked, but no longer fill thelogs.

The rule shown in Figure Firewall Rule to Prevent Logging Broadcasts isconfigured on a test system where the “WAN” is on an internal LAN behind an edgefirewall. To get rid of the log noise to see the things of interest, we addedthis rule to block – but not log – anything with the destination of thebroadcast address of that subnet.

Firewall — Firewall Rule Best Practices (1)

Firewall Rule to Prevent Logging Broadcasts

The best practice is to add similar rules, matching the specifics of any lognoise observed in an environment. Check the firewall logs under Status >System Logs, Firewall tab to see what kind of traffic the firewall isblocking, and review how often it appears in the log. If any particular trafficis consistently being logged more than 5 times a minute, and the traffic is notmalicious or noteworthy, add a block rule for it to reduce log noise.

Logging Practices

Out of the box, pfSense software does not log any passed traffic and logs alldropped traffic. This is the typical default behavior of almost every opensource and commercial firewall. It is the most practical, as logging all passedtraffic is rarely desirable due to the load and log levels generated. Thismethodology is a bit backwards, however, from a security perspective. Blockedtraffic cannot harm a network so its log value is limited, while traffic thatgets passed could be very important log information to have if a system iscompromised. After eliminating any useless block noise as described in theprevious section, the remainder is of some value for trend analysis purposes. Ifsignificantly more or less log volume than usual is observed, it is probablygood to investigate the nature of the logged traffic. OSSEC, an open sourcehost-based intrusion detection system (IDS), is one system that can gather logsfrom a firewall via syslog and alert based on log volume abnormalities.

Firewall — Firewall Rule Best Practices (2024)

FAQs

What is the recommended way of defining the firewall rule? ›

Firewall rules frequently consist of a source address, source port, destination address, destination port, and an action that determines whether to Allow or Deny the packet. In the following firewall ruleset example, the firewall is never directly accessed from the public network.

What are the 4 firewall rules? ›

The Four Basic Firewall Rules Types
  • Allow all: This rule permits all traffic to flow through the firewall, inclusive of all TCP, ICMP, UDP, IPv4, and IPv6 traffic. ...
  • Deny all: This rule blocks all traffic, both inbound and outbound. ...
  • Allow specific: This rule permits only specified types of traffic.
Jun 27, 2023

What is the firewall rule standard? ›

A: The 4 firewall rules are Deny all, Least Privilege, Explicit allow, and Stateful inspection. These rules govern how a firewall handles inbound and outbound network traffic, including traffic involving different subnets and IP addresses. For more details, check out our blog on firewall troubleshooting.

How often should firewall rules be reviewed? ›

As a general guideline, you should review and update your firewall rules and policies at least once a year, or more often if you have a dynamic or high-risk environment.

What specific rule should always be in place while reviewing a firewall ruleset? ›

Firewall rulesets should be as specific as possible with regards to the network traffic they control. To create a ruleset involves determining what types of traffic are required, including protocols the firewall may need to use for management purposes.

What are Layer 7 firewall rules? ›

A Layer 7 firewall operates at the application layer of the OSI. It can analyze and filter traffic based on specific applications or protocols rather than just looking at the source and destination IP addresses and ports. They also provide content filtering, user authentication, and intrusion prevention capabilities.

What is a Layer 3 firewall rule? ›

Layer 3 Firewall rules provide an administrator granular access control of outbound client traffic. With the MR series, outbound traffic refers to client traffic originating from the wireless network that is destined for the wired LAN or Internet.

What are the five 5 steps to configure a firewall? ›

How to Configure a Firewall in 5 Steps
  1. Step 1: Secure your firewall. ...
  2. Step 2: Architect your firewall zones and IP addresses. ...
  3. Step 3: Configure access control lists. ...
  4. Step 4: Configure your other firewall services and logging. ...
  5. Step 5: Test your firewall configuration.

What are the 3 varieties of different firewall rules? ›

What firewall techniques are there?
  • Packet Filtering: Analyzes traffic using IP addresses, port numbers, and protocols.
  • Stateful Inspection: Monitors active connections and the packet's state within a session.
  • Proxy Firewalls: Act as intermediaries and inspect content.

Are firewall rules per user? ›

The firewall is machine-based, not user-based. To have the control you want, you need to install a different firewall. You can, I think, use GPO to dynamically reconfigure the built-in firewall based on who logs on, but of course that introduces much more complexity into the network than installing a "proper" firewall.

Can you make your own firewall rules? ›

Create and edit individual firewall rules

You configure custom rules by defining the target traffic, and the action you want to take on that traffic. Traffic conditions includes protocol, direction, source and destination address, and source/destination port.

What are inbound and outbound firewall rules? ›

Inbound rules control the traffic coming into your system from the network or the internet, aiming to block potentially harmful connections. Outbound rules manage the traffic leaving your system to the network or the internet, preventing potentially malicious software from sending data out.

What are 3 common firewall designs? ›

There are four common architectural implementations of firewalls widely in use. They are packet filtering routers, screened host firewalls, dual-homed firewalls and screened subnet firewalls. Let's understand each one of them in detail.

What is a Layer 4 firewall? ›

Port access control: Layer 4 firewalls allow you to control which ports are open and who can access them, preventing unauthorised ports from being used. Malicious traffic filtering: They can detect and block malicious traffic, such as packets with malicious content or brute force attack attempts through known ports.

Top Articles
Latest Posts
Article information

Author: Amb. Frankie Simonis

Last Updated:

Views: 6006

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Amb. Frankie Simonis

Birthday: 1998-02-19

Address: 64841 Delmar Isle, North Wiley, OR 74073

Phone: +17844167847676

Job: Forward IT Agent

Hobby: LARPing, Kitesurfing, Sewing, Digital arts, Sand art, Gardening, Dance

Introduction: My name is Amb. Frankie Simonis, I am a hilarious, enchanting, energetic, cooperative, innocent, cute, joyous person who loves writing and wants to share my knowledge and understanding with you.