OpenBSD PF Cheatsheet
General PFCTL Commands
pfctl -ddisable packet-filteringpfctl -eenable packet-filteringpfctl -qrun quietpfctl -vvrun even more verbose
Loading PF Rules
pfctl -f /etc/pf.confload /etc/pf.confpfctl -n -f /etc/pf.confparse /etc/pf.conf, but dont load itpfctl -R -f /etc/pf.confload only the FILTER rulespfctl -N -f /etc/pf.confload only the NAT rulespfctl -O -f /etc/pf.confload only the OPTION rules
Clearing PF Rules & Counters
pfctl -F allflush ALL (rules, counters and states)pfctl -F statesflush states (kills active connections)pfctl -F rulesflush only the rules (connections stay open)pfctl -F queueflush only queue’spfctl -F natflush only NATpfctl -F infoflush all stats that are not part of any rule.pfctl -zclear all per-rule counters
note: flushing rules do not touch any existing stateful connections
Output PF Information
pfctl -s rulesshow filter informationpfctl -v -s rulesshow filter information for what FILTER rules hit..pfctl -vvsrshow filter information as above and prepend rule numberspfctl -v -s natshow NAT information, for which NAT rules hit..pfctl -s nat -i xl1show NAT information for interface xl1pfctl -s queueshow QUEUE informationpfctl -s labelshow LABEL informationpfctl -s stateshow contents of the STATE tablepfctl -s infoshow statistics for state tables and packet normalizationpfctl -s allshow everything
Maintaining PF Tables
pfctl -t vhosts -T showshow table vhostspfctl -vvsTablesview global information about all tablespfctl -t vhosts -T add 192.168.1.50add entry to table vhostspfctl -t vhosts -T add 192.168.1.0/16add a network to table vhostspfctl -t vhosts -T delete 192.168.1.0/16delete network from table vhostspfctl -t vhosts -T flushremove all entries from table vhostspfctl -t vhosts -T killdelete table vhosts entirelypfctl -t vhosts -T replace -f /etc/vhostsreload table vhosts on the flypfctl -t vhosts -T test 192.168.1.40find ip address 192.168.1.40 in table vhostspfctl -T load -f /etc/pf.confload a new table definition onlypfctl -t vhosts -T show -voutput stats for each ip address in table vhostspfctl -t vhosts -T zeroreset all counters for table vhosts