How to Set Up blocklistd (formerly blacklistd) with PF on FreeBSD 15
blacklistd is called blocklistd in FreeBSD 15. Configure PF, the daemon and sshd so repeated failed SSH logins are blocked at the firewall, with the FreeBSD 14 names alongside.
This guide sets up the base-system daemon that blocks addresses after repeated failed logins on FreeBSD 15.1, using PF as the firewall and SSH as the protected service. In FreeBSD 15 the daemon is called blocklistd; it is the same tool that FreeBSD 11 through 14 ship as blacklistd. The FreeBSD 15.0 release notes record that the suite was renamed upstream and that existing setups keep working with a warning. If you run FreeBSD 14, follow the same steps with the old names from the table below.
Tools such as Fail2ban and SSHGuard watch log files. blocklistd works differently: daemons that support it, including the sshd in the base system, report each failed or successful authentication directly to it over a socket, and blocklistd adds or removes firewall rules through a helper script.
Names in FreeBSD 15 and FreeBSD 14
| Item | FreeBSD 15 | FreeBSD 14 |
|---|---|---|
| Daemon and rc service | blocklistd | blacklistd |
| Configuration file | /etc/blocklistd.conf | /etc/blacklistd.conf |
| Control utility | blocklistctl | blacklistctl |
| sshd option | UseBlocklist | UseBlacklist |
| PF anchor | blocklistd/* | blacklistd/* |
Requirements
- FreeBSD 15.1-RELEASE (or a supported 14.x release, using the old names).
- A root shell. Every command below runs as
root; prefix them withsudoordoasif you use one of those. - Access to your provider's web console. You are about to enable a firewall over SSH, and a mistake in the ruleset can lock you out.
- The name of your public network interface, shown by
ifconfig. Virtual servers usually havevtnet0, which the examples use.
Step 1: Configure PF with the blocklistd anchor
blocklistd does not write into your main ruleset. It places its block rules in child anchors, so PF needs an anchor line that tells it where to evaluate them. Create /etc/pf.conf with a minimal ruleset that allows SSH and ping and blocks everything else inbound:
ext_if = "vtnet0"
set skip on lo0
scrub in on $ext_if all fragment reassemble
anchor "blocklistd/*" in on $ext_if
block in all
pass out all keep state
antispoof for $ext_if inet
pass in quick on $ext_if inet proto icmp all icmp-type echoreq
pass in quick on $ext_if inet6 proto icmp6 all
pass in quick on $ext_if proto tcp from any to any port 22
The anchor must come before the rules that pass traffic, so that a blocked address is stopped before the SSH rule is reached. Add a pass in quick line for every other service the server offers, such as ports 80 and 443.
Check the file for syntax errors without loading it:
pfctl -vnf /etc/pf.conf
Fix anything it reports, then enable PF and its log interface at boot and start them:
sysrc pf_enable=yes
sysrc pflog_enable=yes
service pf start
service pflog start
Starting PF can freeze the SSH session you are typing in. Open a new connection; if that fails, use the web console to correct /etc/pf.conf.
Step 2: Configure blocklistd
Rules live in /etc/blocklistd.conf, one per line with seven fields: location, socket type, protocol, owner, rule name, number of failures, and block duration. An asterisk means the default or a wildcard. Edit the file so that the [local] section contains a rule for SSH:
# Blocklist rule
# adr/mask:port type proto owner name nfail duration
[local]
ssh stream * * * 3 24h
# adr/mask:port type proto owner name nfail duration
[remote]
#203.0.113.50:ssh * * * * * *
This blocks an address for 24 hours after three failed logins on the SSH port. Durations take the suffixes m, h and d; without a suffix the value is in seconds.
The [remote] section overrides the local rule for specific sources. With * as the failure count an address is never blocked, so uncomment the last line and replace 203.0.113.50 with your own fixed address if you want a guarantee that you cannot lock yourself out.
Enable the daemon and start it:
sysrc blocklistd_enable=yes
sysrc blocklistd_flags="-r"
service blocklistd start
The -r flag makes blocklistd re-add the blocks stored in its database, /var/db/blocklistd.db, when it starts. PF does not keep these rules across a reboot, so without the flag every block would be lost on restart.
Step 3: Tell sshd to report to blocklistd
The base-system sshd does not notify blocklistd by default. Add this line to /etc/ssh/sshd_config:
UseBlocklist yes
Then restart the service:
service sshd restart
UseBlacklist is still accepted as an alias on FreeBSD 15, so a configuration carried over from an earlier release keeps working. If you installed OpenSSH from ports or packages instead of using the base system, check that build's documentation; the option belongs to FreeBSD's sshd.
Step 4: Test and inspect the blocks
From a machine whose address you do not mind blocking for a while, try to log in three times with a wrong password. The fourth connection attempt should time out. On the server, list the blocked addresses:
blocklistctl dump -b
rulename address/ma:port id nfail last access
blocklistd 198.51.100.23/32:22 OK 3/3 2026/11/14 09:12:41
Add -r (blocklistctl dump -br) to see the remaining block time instead of the last access time. The matching PF table sits in a child anchor named after the port:
pfctl -a blocklistd/22 -t port22 -T show
Unblock an address early
blocklistd has no command for removing a single entry. Delete the address from the PF table instead:
pfctl -a blocklistd/22 -t port22 -T delete 198.51.100.23
The address can connect again immediately, but blocklistctl keeps listing it until the entry expires in blocklistd's own database. That is expected behaviour, described in the FreeBSD Handbook.
Troubleshooting
- Nothing is ever blocked. Confirm that
service blocklistd statusreports a running daemon, thatsshdwas restarted after you addedUseBlocklist yes, and thatpfctl -srshows the anchor line. - Blocks disappear after a reboot.
blocklistd_flags="-r"is missing from/etc/rc.conf. - The anchor name does not match. On a system upgraded from FreeBSD 14 with the old daemon names still in use, the anchor is
blacklistd/*. Use one set of names consistently.
Reference: the Blocklistd section of the FreeBSD Handbook and the blocklistd.conf(5) manual page.
Frequently asked questions
Does blocklistd work with IPFW or IPFilter instead of PF?
Yes. The helper script /usr/libexec/blocklistd-helper detects the packet filter in use, and the Handbook describes the setup for IPFW and IPFilter as well. Only the firewall side differs; the daemon and sshd configuration are the same.
Can it block a whole network instead of single addresses?
Yes. A mask in the name field widens the block. A local rule such as 22 stream tcp * */24 3 24h blocks the entire /24 network of an offending address.
Which other services can report to blocklistd?
Only daemons built with support for it. In the base system the Handbook covers sshd and ftpd, the latter enabled with ftpd_flags="-B" in /etc/rc.conf. Services without support still need a log-based tool.
Do successful logins count?
sshd reports successes as well as failures, so blocklistd can tell a legitimate user from a scanner. Mistyping your password once or twice and then logging in does not get you blocked under the three-failure rule above.