The configuration command for the PF firewall.
The pfctl command is the control utility for the Packet Filter (PF) firewall. PF is a software system used for TCP/IP traffic filtering and Network Address Translation (NAT) on Unix-like systems. It also provides traffic shaping, bandwidth control, and packet prioritization. PF was originally developed by Daniel Hartmeier and is now maintained by the OpenBSD team.
To activate PF and have it load its configuration at boot, edit /etc/rc.conf and set:
pf=yes
You can also start and stop PF manually using pfctl:
pfctl -e # Enable PF
pfctl -d # Disable PF
Note that enabling PF does not automatically load rules unless they were loaded at boot or are loaded manually.
PF loads its rules from /etc/pf.conf by default. The file is divided into seven main sections:
These sections should appear in this order in the configuration file.
After boot, PF can be managed using pfctl. Examples:
pfctl -f /etc/pf.conf # Load the pf.conf file
pfctl -nf /etc/pf.conf # Parse the file without loading it
pfctl -sn # Show current NAT rules
pfctl -sr # Show current filter rules
pfctl -ss # Show current state table
pfctl -si # Show filter statistics and counters
pfctl -sa # Show all available information
For a full list of commands, refer to the pfctl man page.