pfSense Shell Commands Cheat Sheet: Console Menu and CLI

Based on the official docs for pfSense CE 2.9.2 and pfSense Plus 26.07.2 Hardware test not run How guides are made and checked

pfSense is built to be run from the web GUI, but the console and shell are where you go when the GUI is slow, unreachable or you’ve locked yourself out. This cheat sheet collects the pfSense commands that Netgate’s own docs give, in one place: the console menu, firewall and state commands, getting back in when locked out, logs, services, the config file, upgrades and the PHP shell.

I run pfSense on my own network. Everything below follows Netgate’s current documentation for pfSense CE 2.9.2 and pfSense Plus 26.07.2 (both released on 19 November 2026).

Getting to a shell

You need one of these:

  • The physical console: a monitor and keyboard, or a serial cable on Netgate appliances.
  • SSH: off by default. See how to enable and secure SSH on pfSense to turn it on and lock it down.
  • Diagnostics > Command Prompt in the GUI, for one-off commands when the GUI still works.

Log in as admin (or root, same password) and you land on the console menu. Pick 8 for a shell. The rest of this page assumes a root shell unless it says “menu option”.

The console menu at a glance

OptionWhat it does
0Logout (shown over SSH)
1Assign interfaces, create VLANs
2Set interface IP addresses; can also switch the GUI back to HTTP and re-enable the LAN anti-lockout rule
3Reset the admin account and set a new password
4Reset to factory defaults
5Reboot
6Halt (shut down)
7Ping a host
8Shell
9pfTop, a live view of firewall states
10Filter logs in real time
11Restart the GUI (nginx)
12PHP shell and pfSense tools
13Upgrade from console
14Enable or disable SSH (sshd)
15Restore a recent configuration
16Restart PHP-FPM

Netgate’s advice: halt with option 6 before pulling the power, and if option 11 doesn’t bring the GUI back, run option 16 as well.

Firewall rules and states (pfctl)

pfSense turns your GUI rules into a ruleset for PF, the FreeBSD packet filter. pfctl shows you what PF is actually running.

pfctl -sr          # firewall rules
pfctl -sn          # NAT rules
pfctl -sa          # everything
pfctl -vvsr        # rules with counters and rule numbers
pfctl -ss          # current state table
pfSsh.php playback pfanchordrill   # rules inside anchors (packages, UPnP)
pfSsh.php playback pftabledrill    # contents of every table (your aliases)

To clear stuck connections from one host, kill its states:

pfctl -k 192.168.1.50                  # states from this host
pfctl -k 192.168.1.50 -k 203.0.113.10  # states from one host to another

Locked out of the GUI?

Turn the firewall off for a moment:

pfctl -d    # disable PF (rules and NAT)
pfctl -e    # enable it again

This is very temporary. Any filter reload, such as saving a rule or an interface event, turns PF back on. It also disables NAT, so anything behind the firewall loses internet while it’s off. Get in, fix the rule, and turn it back on.

Add a precise pass rule with easyrule:

easyrule pass wan tcp 203.0.113.10 192.168.1.1 443   # allow one IP to the GUI
easyrule pass wan icmp 203.0.113.10 192.168.1.1      # no port for ICMP

The format is easyrule pass <interface> <protocol> <source> <destination> [port]. Run easyrule with no arguments to see the usage text.

Block, list and unblock an address:

easyrule block wan 198.51.100.7
easyrule showblock wan
easyrule unblock wan 198.51.100.7

Blocks only work by source address, and they’re added to an alias, the same way the block button in the firewall log works.

Last resort, allow everything on WAN:

pfSsh.php playback enableallowallwan

Netgate is blunt about this one: be extremely careful, it’s only meant to be temporary. It adds allow-all rules for IPv4 and IPv6 on WAN. Delete them as soon as you have proper rules in place.

If the problem is a forgotten password rather than a rule, use menu option 3 instead.

Logs

tail -F /var/log/filter.log | filterparser.php   # firewall log, readable, live

Menu option 10 shows the raw filter log, and option 9 (pfTop) shows live states and how much data each one is moving.

Services, DHCP and the GUI

The svc playback script controls the same services as Status > Services:

pfSsh.php playback svc restart unbound
pfSsh.php playback svc stop miniupnpd
pfSsh.php playback svc restart openvpn client 2
pfSsh.php playback svc start captiveportal MyZone

The service name matches Status > Services. Put quotes around names with spaces. Services with several instances (OpenVPN, Captive Portal) take an extra option to pick which one.

Other handy playback scripts:

pfSsh.php playback restartdhcpd      # stop and start the DHCP server
pfSsh.php playback restartipsec      # rewrite and reload IPsec
pfSsh.php playback restartallwan     # reapply every WAN-type interface
pfSsh.php playback gatewaystatus     # gateway status and stats
pfSsh.php playback generateguicert   # new self-signed GUI certificate
pfSsh.php playback enablesshd        # turn on SSH (same as menu option 14)
pfSsh.php playback listpkg           # installed packages
pfSsh.php playback changepassword    # change a user's password

Run one playback script per shell session. The PHP shell isn’t designed to run several in a row, so exit and start again, or just run each one from the normal shell as above.

The configuration file

Everything pfSense knows, including package settings, lives in one XML file: /conf/config.xml.

viconfig                 # edit the running config in vi; clears the cache when you exit
rm /tmp/config.cache     # clear the cache after editing config.xml any other way

viconfig opens the file in vi; if vi is new to you, keep the basic vi commands handy. After editing, reboot or save the relevant page in the GUI so the change is applied. Netgate warns that even experienced admins break the config this way, so take a backup first (Diagnostics > Backup & Restore). If a change goes wrong, menu option 15 lists recent configurations and restores one.

Upgrades

pfSense-upgrade -c       # check if an update is available
pfSense-upgrade -d -c    # same check, with debug output
pfSense-upgrade          # run the upgrade

Menu option 13 runs the same script. For the full process and fixes for “not possible to determine pfSense remote version”, see updating pfSense from the command line. A Netgate developer also warns against running pfSense-upgrade from cron, because there is no way to downgrade.

PHP shell basics (menu option 12)

The PHP shell, also started with pfSsh.php, runs PHP inside the live system. It’s mainly for developers, but a few things are worth knowing:

pfSense shell: print(config_get_path('system/hostname') . "\n");
pfSense shell: exec
  • Type one or more lines, then exec on its own line to run them.
  • Start a line with ! to run a normal shell command.
  • record <name> and stoprecording save a session you can replay later with playback <name>. Saved sessions live in /etc/phpshellsessions.

Troubleshooting

  • pfctl -d “doesn’t work”: something reloaded the filter and switched PF back on. Act quickly, or add a proper rule with easyrule pass instead.
  • PHP shell commands do nothing: you haven’t typed exec. Nothing runs until you do.
  • A second playback script fails in the PHP shell: exit and start the shell again, or run it from the normal shell with pfSsh.php playback <script>.
  • Your edit to config.xml didn’t show up: the GUI reads /tmp/config.cache. Use viconfig, or remove the cache by hand and then save or reboot.
  • Old SSH client can’t connect after upgrading to 2.9: 2.9.0 removed weaker SSH algorithms. Update the client, or see how to fix “no matching host key type found”.

Keeping it safe

  • Root shell means full control. Netgate calls the shell very powerful and potentially very dangerous. Only give SSH to people you’d trust with the whole firewall, and use key-only login.
  • Never leave pfctl -d or enableallowallwan in place. Both open the firewall. Undo them as soon as you’re back in.
  • Keep pfSense patched. Netgate published a long list of web GUI advisories on 17 November 2026 (mostly authenticated command execution) fixed in Plus 26.07.1 and CE 2.9.1, and 26.07.2 and 2.9.2 followed two days later with PHP and nginx updates. If you can’t upgrade yet, the System Patches package carries the recommended fixes for recent releases.
  • Plan for IKEv1 going away. Netgate has deprecated IKEv1 and plans to remove it within about a year. Move any IPsec tunnels to IKEv2.

Sources