BLOCKLISTD(8)
β¨ blocklistd(8) β¨
okay bestie so you're looking at the manual page for blocklistd, from the System Manager's Manual β it's a daemon that blocks and releases ports on demand so nobody can DoS-abuse your box π
π NAME π
blocklistd β block and release ports on demand to avoid DoS abuse
πΈ SYNOPSIS πΈ
blocklistd [-dfrv] [-C controlprog] [-c configfile] [-D dbfile]
[-P sockpathsfile] [-R rulename] [-s sockpath] [-t timeout]
π DESCRIPTION π
So blocklistd is a daemon, kinda like syslogd(8)'s cousin π― β it listens on sockets at the paths listed in the sockpathsfile, waiting for notifications from other daemons about connection attempts that either succeeded or failed. If you don't give it such a file, then it only listens to the socket path you gave in sockpath β and if that isn't specified either, it goes to /var/run/blocklistd.sock. Defaults, amirite π«Ά
Every notification carries an (action, port, protocol, address, owner) tuple that identifies the remote connection plus the action. That tuple gets checked against entries from the configfile, using the syntax in blocklistd.conf(5). If something matches, a state entry is created for that tuple. Each entry has a number-of-tries limit and a duration. periodt β¨
If configfile is a directory, or a directory exists with the same name as configfile but with ".d" appended to it, then every file in that directory gets read as a configuration file. And if configfile exists as a file, it's processed before the contents of the configfile.d directory β assuming that directory also exists. stacking order matters, bestie π
Here's how blocklistd does its config-entry matching: the client side passes the file descriptor associated with the connection it wants blocklisted, plus it passes socket credentials.
That file descriptor is used to get info β address and port β about the remote side with getpeername(2), and about the local side with getsockname(2). detective work π
By looking at the local side's port, blocklistd can figure out whether the client program "owns" that port. By looking at the optional address portion on the local side, it can match interfaces. By looking at the remote address, it can match specific allow or deny rules. and finally, it can peek at the socket credentials to match the user in the configuration file. the full vibe check π₯
β οΈ ngl this all works great for TCP sockets, but you cannot rely on it for unbound UDP sockets. It's also less meaningful for connections using non-privileged ports. On the flip side: if a request comes in whose local endpoint indicates a UDP privileged port, we can presume the client was privileged enough to acquire that port in the first place. slay for them π
Once an entry matches, blocklistd can do a bunch of different things. If the action is "add" and the tries limit is reached, then a control script controlprog gets invoked with these arguments:
control add <rulename> <proto> <address> <mask> <port>
...and it should invoke a packet filter command to block the connection specified by those arguments. The rulename argument can be set from the command line (default is blocklistd). The script could print a numerical id to stdout as a handle for the rule, which you can use later to remove that connection β but that's not required, because all the info needed to remove the rule is kept anyway. generous of it π
If the action is "rem", then that same control script gets invoked like this:
control rem <rulename> <proto> <address> <mask> <port> <id>
where id is the number that came back from the "add" action.
blocklistd keeps a database of known connections in dbfile. On startup it reads entries from that file and updates its internal state. memory queen π
Every timeout seconds (default 15), blocklistd checks the list of active entries and removes entries and block rules using the control program, as necessary.
The following options are available:
π¦ OPTIONS π¦
-C controlprogβ use controlprog to talk to the packet filter instead of the default, which is/usr/libexec/blocklistd-helper. The following arguments get passed to the control program:actionβ the action to perform:add,rem, orflush; to add, remove or flush a firewall rule.nameβ the rule name.protocolβ the optional protocol name (can be empty):tcp,tcp6,udp,udp6.addressβ the IPv4 or IPv6 numeric address to be blocked or released.maskβ the numeric mask to be applied to the blocked or released addressportβ the optional numeric port to be blocked (can be empty).idβ for packet filters that support removing rules by rule identifier, the identifier of the rule to be removed. Theaddcommand is expected to return the rule identifier string to stdout.
-c configurationβ the name of the configuration file to read. When-cisn't given, the default is/etc/blocklistd.conf.-D dbfileβ the Berkeley DB file whereblocklistdstores its state. Defaults to/var/db/blocklistd.db.-dβ normallyblocklistddisassociates itself from the terminal, but with the-dflag it stays in the foreground instead. hi bestie, still here π-fβ truncate the state database, and flush all the rules named rulename by invoking the control script like this:
control flush <rulename>
-P sockpathsfileβ a file containing a list of pathnames, one per line, thatblocklistdwill create sockets to listen to. super useful for chrooted environments π§-R rulenameβ specify the default rule name for the packet filter rules β usuallyblocklistd.-rβ re-read the firewall rules from the internal database, then remove them and re-add them. this is the fix for packet filters that don't retain their state across reboots π-s sockpathβ add sockpath to the list of Unix socketsblocklistdlistens to.-t timeoutβ the interval in seconds thatblocklistdpolls the state file to update the rules.-vβ makeblocklistdprint diagnostic messages to stdout instead of tosyslogd(8).
π SIGNAL HANDLING π
blocklistd deals with the following signals:
HUPβ receiving this signal makesblocklistdre-read the configuration file.INT,TERM&QUITβ these signals tellblocklistdto exit in an orderly fashion. bye bestie, no mess πUSR1β this signal tellsblocklistdto increase the internal debugging level by 1.USR2β this signal tellsblocklistdto decrease the internal debugging level by 1.
π FILES π
/usr/libexec/blocklistd-helperβ shell script invoked to interface with the packet filter./etc/blocklistd.confβ configuration file./var/db/blocklistd.dbβ database of current connection entries./var/run/blocklistd.sockβ socket to receive connection notifications.
β SEE ALSO β
blocklistd.conf(5), blocklistctl(8), ipf(8), ipfw(8), pfctl(8), syslogd(8)
π HISTORY π
blocklistd first appeared in NetBSD 7. FreeBSD support for blocklistd was implemented in FreeBSD 11. glow-up pipeline fr fr β¨
π AUTHORS π
Christos Zoulas
Debian β February 25, 2025 π«Ά that's the source and date, bestie, go forth and block those ports π β¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 2015 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms