Written for pfSense Plus 26.03 and pfSense CE 2.8, and checked against Netgate's pfSense documentation. pfSense is set up in its web interface; these are for the shell (console menu option 8, or SSH as admin), mostly for troubleshooting. Interface names are FreeBSD device names such as igc1 or vtnet0, not WAN and LAN, except in EasyRule. Changes made by editing files or with pfctl aren't kept unless they're in config.xml, and are replaced when the firewall reloads its rules. Addresses are examples, so swap in your own.
Official links: pfSense documentation, Using the PHP shell.
Console and shell basics #
-
Open the console menu from an SSH shellpfSense shell
/etc/rc.initial -
Show the versionpfSense shell
cat /etc/version -
Show interfaces, addresses and link statepfSense shell
ifconfig -
Show one interfacepfSense shell
ifconfig igc1 -
Show uptime and loadpfSense shell
uptime -
Show the busiest processes and threadspfSense shell
top -aSH -
Show disk spacepfSense shell
df -h -
Show memory and swappfSense shell
swapinfo -h
Firewall rules and states (pf) #
-
Show the loaded firewall rulespfSense shell
pfctl -sr -
Show the rules with counterspfSense shell
pfctl -vvsr -
Show the NAT rulespfSense shell
pfctl -sn -
Show firewall status and counterspfSense shell
pfctl -si -
Show the state tablepfSense shell
pfctl -ss -
Show states for one addresspfSense shell
pfctl -ss | grep 192.168.1.25 -
Kill the states from one addresspfSense shell
pfctl -k 192.168.1.25Warning: Cuts that host's connections straight away.
-
Kill the states between two addressespfSense shell
pfctl -k 192.168.1.25 -k 198.51.100.10 -
List the tables (aliases, bogons, blocklists)pfSense shell
pfctl -s Tables -
Show the addresses in an alias or tablepfSense shell
pfctl -t bogons -T show -
Reload the firewall rules from the configpfSense shell
/etc/rc.filter_configure -
Turn the firewall off to get back inpfSense shell
pfctl -dWarning: Turns off all filtering and NAT, so the internet stops working too. Run pfctl -e or reload the rules as soon as you've fixed things.
-
Turn the firewall back onpfSense shell
pfctl -e -
Show how many states are in usepfSense shell
pfctl -si | grep -A1 'State Table' -
Watch states and traffic livepfSense shell
pftop -
List addresses locked out after failed loginspfSense shell
pfctl -t sshguard -T show -
Unblock an address locked out after failed loginspfSense shell
pfctl -t sshguard -T delete 192.168.1.25
EasyRule from the shell #
-
Block an address on WANpfSense shell
easyrule block wan 192.168.1.25 -
List addresses EasyRule has blockedpfSense shell
easyrule showblock wan -
Remove an EasyRule blockpfSense shell
easyrule unblock wan 192.168.1.25 -
Add a pass rule for one connectionpfSense shell
easyrule pass wan tcp 192.168.1.25 198.51.100.10 443
Recovery and console fixes #
-
Restore a recent config backup (console option 15)pfSense shell
/etc/rc.restore_config_backup -
Allow the web interface from WAN to get back inpfSense shell
pfSsh.php playback enableallowallwanWarning: Opens every port on WAN to everyone. Use it only to recover access, then remove the rule straight away.
-
Turn off the web interface's HTTP referer checkpfSense shell
pfSsh.php playback disablereferercheck -
Make a new self-signed certificate for the web interfacepfSense shell
pfSsh.php playback generateguicert -
Turn on SSHpfSense shell
pfSsh.php playback enablesshd -
Turn off the DHCP serverpfSense shell
pfSsh.php playback disabledhcpd -
List boot environments (ZFS)pfSense shell
bectl list -
Delete an old boot environment to free space (ZFS)pfSense shell
bectl destroy default_20260301Warning: Can't be undone. Don't delete the one marked active (N or R in bectl list).
Logs #
-
Watch the firewall log in plain textpfSense shell
tail -F /var/log/filter.log | filterparser.php -
Watch the system logpfSense shell
tail -F /var/log/system.log -
Show recent DHCP server log entriespfSense shell
tail -n 50 /var/log/dhcpd.log -
Watch the IPsec logpfSense shell
tail -F /var/log/ipsec.log -
Watch the OpenVPN logpfSense shell
tail -F /var/log/openvpn.log -
Watch the gateway monitoring logpfSense shell
tail -F /var/log/gateways.log -
Watch the DNS resolver logpfSense shell
tail -F /var/log/resolver.log -
Watch the Kea DHCP logpfSense shell
tail -F /var/log/dhcpd.log
Packet capture and testing #
-
Capture traffic to and from an addresspfSense shell
tcpdump -ni igc1 host 192.168.1.25 -
Capture one portpfSense shell
tcpdump -ni igc1 port 443 -
Save a capture to open in WiresharkpfSense shell
tcpdump -ni igc1 -w /tmp/capture.pcap host 192.168.1.25 -
See blocked packets as they're loggedpfSense shell
tcpdump -n -e -ttt -i pflog0 -
Ping from a specific source addresspfSense shell
ping -S 192.168.1.1 198.51.100.10 -
Trace the route to a hostpfSense shell
traceroute -n 198.51.100.10 -
Look up a name with the firewall's DNSpfSense shell
drill www.example.com -
Test a TCP port from the firewallpfSense shell
nc -vz 198.51.100.10 443
Routing, ARP and listening services #
-
Show the routing tablepfSense shell
netstat -rn -
Show the route to one addresspfSense shell
route -n get 198.51.100.10 -
Show the ARP tablepfSense shell
arp -an -
Show which services are listeningpfSense shell
sockstat -4l -
Show traffic per interface livepfSense shell
systat -ifstat 1 -
Show network buffer use (mbufs)pfSense shell
netstat -m -
Show per-interface packet and error counterspfSense shell
netstat -i
DHCP, DNS and NTP #
-
List DHCP leases (Kea)pfSense shell
cat /var/lib/kea/dhcp4.leases -
Find a lease by MAC or namepfSense shell
grep -i aa:bb:cc:00:01:00 /var/lib/kea/dhcp4.leases -
Restart the DHCP serverpfSense shell
pfSsh.php playback restartdhcpd -
Look up a name in the DNS resolver's cachepfSense shell
unbound-control -c /var/unbound/unbound.conf lookup www.example.com -
Flush one name from the DNS resolver's cachepfSense shell
unbound-control -c /var/unbound/unbound.conf flush www.example.com -
Flush the whole DNS resolver cachepfSense shell
unbound-control -c /var/unbound/unbound.conf reload -
Show DNS resolver statisticspfSense shell
unbound-control -c /var/unbound/unbound.conf stats_noreset -
Show NTP peers and sync statuspfSense shell
ntpq -pn
High availability (CARP) #
-
Show CARP status on each interfacepfSense shell
ifconfig | grep carp -
Put this firewall into CARP maintenance (hand over to the backup)pfSense shell
pfSsh.php playback disablecarpWarning: The backup firewall takes over. Run enablecarp to come back.
-
Turn CARP back onpfSense shell
pfSsh.php playback enablecarp -
Show pfsync state synchronisationpfSense shell
ifconfig pfsync0
Traffic shaping and limiters #
-
Show limiters and their queuespfSense shell
dnctl pipe show -
Show limiter schedulerspfSense shell
dnctl sched show -
Show ALTQ shaper queues with counterspfSense shell
pfctl -vvsq
Services #
-
Restart a service (unbound, dhcpd, ntpd, sshd)pfSense shell
pfSsh.php playback svc restart unbound -
Restart the web interfacepfSense shell
/etc/rc.restart_webgui -
Restart PHP-FPM when the web interface hangspfSense shell
/etc/rc.php-fpm_restart -
Restart an OpenVPN clientpfSense shell
pfSsh.php playback svc restart openvpn client 1 -
Restart an OpenVPN serverpfSense shell
pfSsh.php playback svc restart openvpn server 1 -
Change a user's password (it asks for it)pfSense shell
pfSsh.php playback changepassword admin -
Restart IPsecpfSense shell
pfSsh.php playback restartipsec
VPN status #
-
Show IPsec tunnels and SAspfSense shell
swanctl --list-sas -
Show IPsec connections that are configuredpfSense shell
swanctl --list-conns -
Show WireGuard tunnels and peerspfSense shell
wg show -
Show OpenVPN processespfSense shell
ps auxww | grep openvpn
Configuration and backups #
-
Back up the config to a filepfSense shell
cp /conf/config.xml /root/config-$(date +%Y%m%d).xml -
List the automatic config backupspfSense shell
ls -l /conf/backup/ -
Edit the config file directly (careful)pfSense shell
viconfigWarning: A mistake can stop pfSense booting cleanly. Back up config.xml first.
-
Clear the cached config after editing config.xmlpfSense shell
rm /tmp/config.cache -
Reload every setting from the configpfSense shell
/etc/rc.reload_all
Packages and upgrades #
-
Check for a new pfSense versionpfSense shell
pfSense-upgrade -c -
Upgrade pfSensepfSense shell
pfSense-upgradeWarning: Reboots the firewall. Back up the config and read the upgrade guide first.
-
List installed packagespfSense shell
pkg info -
Show pfSense packages availablepfSense shell
pkg search pfSense-pkg -
List installed pfSense packagespfSense shell
pfSsh.php playback listpkg -
Install a packagepfSense shell
pfSsh.php playback installpkg pfBlockerNG -
Remove a packagepfSense shell
pfSsh.php playback uninstallpkg pfBlockerNG -
RebootpfSense shell
shutdown -r nowWarning: Stops all traffic until it's back up.
-
Shut downpfSense shell
shutdown -p now