OpenBSD PF Cheatsheet
General PFCTL Commands
pfctl -d
disable packet-filteringpfctl -e
enable packet-filteringpfctl -q
run quietpfctl -vv
run even more verbose
Loading PF Rules
pfctl -f /etc/pf.conf
load /etc/pf.confpfctl -n -f /etc/pf.conf
parse /etc/pf.conf, but dont load itpfctl -R -f /etc/pf.conf
load only the FILTER rulespfctl -N -f /etc/pf.conf
load only the NAT rulespfctl -O -f /etc/pf.conf
load only the OPTION rules
Clearing PF Rules & Counters
pfctl -F all
flush ALL (rules, counters and states)pfctl -F states
flush states (kills active connections)pfctl -F rules
flush only the rules (connections stay open)pfctl -F queue
flush only queue’spfctl -F nat
flush only NATpfctl -F info
flush all stats that are not part of any rule.pfctl -z
clear all per-rule counters
note: flushing rules do not touch any existing stateful connections
Output PF Information
pfctl -s rules
show filter informationpfctl -v -s rules
show filter information for what FILTER rules hit..pfctl -vvsr
show filter information as above and prepend rule numberspfctl -v -s nat
show NAT information, for which NAT rules hit..pfctl -s nat -i xl1
show NAT information for interface xl1pfctl -s queue
show QUEUE informationpfctl -s label
show LABEL informationpfctl -s state
show contents of the STATE tablepfctl -s info
show statistics for state tables and packet normalizationpfctl -s all
show everything
Maintaining PF Tables
pfctl -t vhosts -T show
show table vhostspfctl -vvsTables
view global information about all tablespfctl -t vhosts -T add 192.168.1.50
add entry to table vhostspfctl -t vhosts -T add 192.168.1.0/16
add a network to table vhostspfctl -t vhosts -T delete 192.168.1.0/16
delete network from table vhostspfctl -t vhosts -T flush
remove all entries from table vhostspfctl -t vhosts -T kill
delete table vhosts entirelypfctl -t vhosts -T replace -f /etc/vhosts
reload table vhosts on the flypfctl -t vhosts -T test 192.168.1.40
find ip address 192.168.1.40 in table vhostspfctl -T load -f /etc/pf.conf
load a new table definition onlypfctl -t vhosts -T show -v
output stats for each ip address in table vhostspfctl -t vhosts -T zero
reset all counters for table vhosts