Common pfSense Configuration Recipes
This section collects the most frequently requested pfSense configuration recipes. Each recipe includes a task description and step-by-step instructions. The recipes assume familiarity with basic pfSense configuration and the web management interface.
Before following any recipe, create a configuration backup: Diagnostics - Backup & Restore. This enables rollback in case of errors.
Transparent Firewall (Transparent Bridge)
A transparent firewall operates at OSI layer 2, filtering traffic without modifying the network’s IP addressing. pfSense is placed between two network segments as an invisible bridge, allowing traffic filtering without reconfiguring IP addresses on hosts.
Step-by-Step
- Navigate to Interfaces - Assign and confirm both interfaces (e.g., WAN and LAN) are assigned
- Navigate to Interfaces - Bridges and create a bridge:
- Member Interfaces - select both interfaces
- Navigate to Interfaces - Assign, assign the created bridge as a new interface (e.g., BRIDGE0)
- Configure an IP address on the bridge interface (for pfSense management access)
- Remove IP addresses from the original member interfaces
- Navigate to System - Advanced - System Tunables and set:
net.link.bridge.pfil_member= 0net.link.bridge.pfil_bridge= 1
- Create firewall rules on the bridge interface to filter traffic
Important: in bridge mode, pfSense does not perform NAT. Routing remains on the upstream router. Firewall rules apply to the bridge interface, not to individual bridge members.
DNS over TLS (DoT)
DNS over TLS encrypts DNS queries between pfSense and upstream DNS servers, protecting them from interception and modification by ISPs or attackers.
Step-by-Step
- Navigate to System - General Setup
- Configure DNS servers with DoT support:
| DNS Provider | IP Address | Hostname (TLS) |
|---|---|---|
| Cloudflare | 1.1.1.1 | cloudflare-dns.com |
| 8.8.8.8 | dns.google | |
| Quad9 | 9.9.9.9 | dns.quad9.net |
- Navigate to Services - DNS Resolver
- Enable DNS Resolver if not already enabled
- Enable DNS Query Forwarding
- Enable Use SSL/TLS for outgoing DNS Queries to Forwarding Servers
- In the Custom Options section, add (optional):
server:
tls-cert-bundle: "/etc/ssl/cert.pem"- Save and apply changes
DNS over HTTPS (DoH)
pfSense does not natively support DoH in the DNS Resolver. To implement DoH, use the dns-over-https-proxy package or configure Unbound to forward to a local DoH proxy. DoT is the recommended option for pfSense.
Blocking Specific Countries (GeoIP)
GeoIP blocking restricts traffic from specific countries. This is used to protect servers from mass attacks originating from regions with no business relationship.
Step-by-Step
- Register at MaxMind.com and obtain a free GeoLite2 license key
- Navigate to Firewall - Aliases and create a new alias:
- Name - e.g., Blocked_Countries
- Type - URL Table (IPs)
- URL - enter the URL for IP ranges of the target countries
- Alternative approach - install the pfBlockerNG package:
- System - Package Manager - Available Packages - pfBlockerNG-devel
- Configure GeoIP under Firewall - pfBlockerNG - GeoIP
- Select continents and countries to block
- pfBlockerNG automatically creates aliases and firewall rules
- Create a block rule on WAN:
Action: Block
Interface: WAN
Source: Blocked_Countries (alias)
Destination: anyWarning: GeoIP databases are not 100% accurate. VPNs and proxy servers can bypass geographic blocking. Use GeoIP as an additional layer of defense, not the sole control.
Port Knocking
Port knocking is a method of hiding services by requiring a sequence of connection attempts to specific ports before granting access. It is implemented through a series of firewall rules with state tracking.
Step-by-Step
- Define the port sequence (e.g., TCP 7000, TCP 8000, TCP 9000)
- Navigate to Firewall - Rules - WAN
- Create rules for each step in the sequence using pf anchors via custom rules or the knockd package:
Package-based approach:
- Install the package via pkg: connect to the pfSense console
- Create a knockd configuration file:
[options]
logfile = /var/log/knockd.log
[openSSH]
sequence = 7000,8000,9000
seq_timeout = 10
command = /sbin/pfctl -t knock_allowed -T add %IP%
tcpflags = syn
[closeSSH]
sequence = 9000,8000,7000
seq_timeout = 10
command = /sbin/pfctl -t knock_allowed -T delete %IP%
tcpflags = syn- Create a
knock_allowedalias table in the firewall rules - Create a rule on WAN allowing SSH access from sources in the
knock_allowedtable
Forced DNS Redirect (Traffic Redirect)
DNS redirect forces all DNS queries from LAN to pass through the pfSense DNS server, even when clients have hardcoded alternative DNS servers (e.g., 8.8.8.8 configured directly on a device).
Step-by-Step
- Navigate to Firewall - NAT - Port Forward
- Create a redirect rule:
Interface: LAN
Protocol: TCP/UDP
Source: LAN net
Source port: any
Destination: any (Invert Match disabled)
Destination: NOT "LAN Address" (to exclude queries to pfSense itself)
Destination port: 53
Redirect target IP: 127.0.0.1
Redirect target port: 53- Repeat for DNS over TLS (port 853) to block direct DoT queries from clients:
Action: Block
Interface: LAN
Protocol: TCP
Source: LAN net
Destination: any
Destination port: 853- Confirm the DNS Resolver is running and bound to the LAN interface
Multiple Public IPs
Scenario: the ISP has provided a block of public IP addresses, and different IPs need to be mapped to different internal servers.
Step-by-Step
- Navigate to Firewall - Virtual IPs and add each additional public IP:
- Type - IP Alias (if the IP is from the same subnet as WAN) or Other (for separate subnets)
- Interface - WAN
- Address - the public IP address
- Navigate to Firewall - NAT - 1:1 to create one-to-one mappings:
- Interface - WAN
- External subnet IP - public IP
- Internal IP - private IP of the internal server
- Or use Firewall - NAT - Port Forward to redirect specific ports:
- Destination - select the Virtual IP
- Redirect target IP - internal server IP
- Create firewall rules on WAN to allow inbound traffic to the Virtual IPs
For NAT configuration details, see the pfSense NAT section.
DMZ Setup
A DMZ (Demilitarized Zone) is an isolated network segment for servers accessible from the internet. The DMZ separates public-facing servers from the internal network.
Step-by-Step
- Connect a third network interface to pfSense (physical or VLAN)
- Navigate to Interfaces - Assign and assign the new interface
- Configure the DMZ interface:
- IPv4 Address - e.g., 10.0.100.1/24
- Enable Interface - checked
- Configure DHCP for DMZ (optional): Services - DHCP Server - DMZ
- Create firewall rules:
On WAN - allow inbound traffic to DMZ servers:
Action: Pass
Interface: WAN
Destination: DMZ net (specific servers and ports)On DMZ - allow servers internet access, deny access to LAN:
Action: Block
Interface: DMZ
Source: DMZ net
Destination: LAN net
Action: Pass
Interface: DMZ
Source: DMZ net
Destination: anyOn LAN - allow access from LAN to DMZ (optional):
Action: Pass
Interface: LAN
Source: LAN net
Destination: DMZ net- Configure NAT Port Forward to map ports from WAN to DMZ servers
Secure Remote Administration
Remote access to the pfSense web GUI over the internet requires additional security measures.
Step-by-Step
- Change the web GUI port: System - Advanced - Admin Access, set a non-standard HTTPS port (e.g., 8443)
- Restrict access by IP: create an alias with permitted administrator IP addresses
- Create a rule on WAN:
Action: Pass
Interface: WAN
Protocol: TCP
Source: Admin_IPs (alias)
Destination: WAN address
Destination port: 8443Recommended approach - use VPN instead of direct access:
- Configure OpenVPN or WireGuard on pfSense (see VPN section)
- Connect to pfSense through the VPN tunnel
- Do not expose the web GUI on WAN
Enable brute-force protection: System - Advanced - Login Protection
- Set the lockout threshold (e.g., 5 attempts within 5 minutes)
- Lockout duration: 30 minutes
Bandwidth Monitoring per IP
Track bandwidth consumption by each host on the network.
Step-by-Step
Built-in monitoring - Status - Traffic Graph:
- Shows real-time traffic per interface
- Limited to the current moment with no historical data
ntopng package (recommended for detailed monitoring):
- Install: System - Package Manager - Available Packages - ntopng
- Configure: Diagnostics - ntopng Settings
- Select interfaces to monitor (LAN, WAN)
- ntopng web interface available at https://pfSense_IP:3001
Darkstat package (lightweight alternative):
- Install through Package Manager
- Configure monitoring interfaces
- Displays statistics by host and protocol
BandwidthD package:
- Generates per-IP bandwidth consumption graphs
- Stores historical data
- Suitable for reporting
For comprehensive pfSense monitoring with Prometheus, see the monitoring section.
VPN with Split DNS
Split DNS separates name resolution: corporate domains resolve through an internal DNS server via VPN, while all other queries use public DNS servers.
Step-by-Step
Configure an OpenVPN server on pfSense (see VPN section)
In the OpenVPN server settings:
- Do not enable the Redirect IPv4 Gateway flag (to avoid routing all traffic through VPN)
- In the DNS Server field, enter the IP address of the corporate DNS server
- In the DNS Domain field, enter the corporate domain (e.g., corp.example.com)
Navigate to Services - DNS Resolver
Under Domain Overrides, add an entry:
- Domain - corporate domain (corp.example.com)
- IP Address - internal DNS server address
Configure routing:
- In the OpenVPN server settings, add IPv4 Local Network - subnets accessible through VPN
- The client receives routes only to the specified subnets
On the client side, ensure the corporate domain DNS suffix is delivered through the VPN connection
For general VPN configuration, see the pfSense VPN section. Troubleshooting topics are covered in the troubleshooting guide .