Skip to content

Instantly share code, notes, and snippets.

@kstevenson722
Last active February 17, 2021 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kstevenson722/2e6f0ad3a717095ca00cdd361fa6acd3 to your computer and use it in GitHub Desktop.
Save kstevenson722/2e6f0ad3a717095ca00cdd361fa6acd3 to your computer and use it in GitHub Desktop.
Guide pfsense 2.4.5 Firewall and NAT Rules

Guide to pfsense 2.4.5 Firewall and NAT Rules

This video ๐Ÿ”— https://youtu.be/lZjMxdBPH7M

SUPPORT MY WORK - Everything Helps


YouTube ๐Ÿ”— https://YouTube.GetMeTheGeek.com

Buy Me a Coffee โ˜• https://www.buymeacoffee.com/getmethegeek

Hire US for your Project ๐Ÿ”— https://getmethegeek.com

Overview

In this tutorial

  • pfsense rule sets
  • How to write firewall rules
  • Setup firewall rules
  • Setup NAT rules

Firewall rules do 3 different things with traffic.

  • Pass - allows traffic to pass
  • Reject - drops traffic and alerts traffic sender
  • Block - drops traffic silently

When traffic, a packet arrives at an interface. That packet is checked against the firewall rules in order. When a rule is found that matches the rule action is taken (Pass, Reject or Block).

If no rule matches for the packet the packet will be blocked by default.

When to use Block or Reject

  • When in doubt, use block
  • Reject send a response to the sender
    • This could alert an attacker that there is a firewall or device at the particular IP address and prompt them to scan all the ports for a hole or vulnerability.
    • When you use Block the sender or attacker never gets a response. They don't know if there is something at the IP address not responding or if there is nothing there at all. The IP is less attractive to the attacker.
    • Rule of thumb don't use reject on a WAN interface
    • Reject will allow for faster failure for applications trying to connect. This can be good for applications on a LAN.

pfsense Rule Sets

  • Each interface has a separate rule set for incoming traffic
  • Virtual interfaces such as VPN also have separate rule sets for incoming traffic
  • Each Interface Group also has its own rule set
  • Floating Rules
  • Nat port forwarding rules
  • Installed services can automatically add rules

Rule Ordering

pfsense evaluates rules in the following order:

  1. NAT rules
  2. Service rules
  3. Floating rules
  4. Interface Group and VPN rules
  5. Interface rules

Firewall Rule Tips

  • Order matters
    • Rules are check one at a time in order from first to last
    • Rule checking stops after the first match
      • The rule you want might not ever get checked!
  • Order rules from most specific to most general
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment