BLACKLISTD(8)
π€ BLACKLISTD(8) β the blacklistd girlies' guide
okay so real talk, this is the BLACKLISTD(8) page from the System Manager's Manual and it's basically the bouncer at the club of your network. let's get into it bestie β¨
πΈ NAME πΈ
blacklistd β block and release ports on demand to avoid DoS abuse π
β¨ SYNOPSIS β¨
blacklistd [-dfrv] [-C controlprog] [-c configfile] [-D dbfile]
[-P sockpathsfile] [-R rulename] [-s sockpath] [-t timeout]
π DESCRIPTION π
okay so blacklistd is a daemon, kinda like syslogd(8)'s cooler cousin. it listens on sockets at the paths listed in the sockpathsfile, waiting for notifications from other daemons about connection attempts that either slayed or flopped. π«Ά
if no such file is specified, then it only listens to the socket path given by sockpath, or β if that's also not specified β to /var/run/blocklistd.sock. no cap.
every notification carries an (action, port, protocol, address, owner) tuple that IDs the remote connection plus the action. that tuple gets checked against the entries in the configfile, using the syntax from blacklistd.conf(5). if an entry matches, a state entry is born for that tuple β and each entry comes with a number-of-tries limit and a duration. it's giving β¨consequencesβ¨.
if configfile is a directory, or a directory exists with the same name as configfile with ".d" appended to it, every file in that directory gets read as a config file. and if configfile exists as a file, it gets processed before the contents of the configfile.d directory β assuming that one exists too.
here's the tea on how blacklistd does config entry matching: the client side passes the file descriptor tied to the connection it wants blacklisted, plus the socket credentials.
that file descriptor gets used to pull info (address and port) about the remote side with getpeername(2), and about the local side with getsockname(2).
by examining the port of the local side, blacklistd can tell whether the client program "owns" the port. by examining the optional address portion on the local side, it can match interfaces. and by examining the remote address, it can match specific allow or deny rules. π―
finally, blacklistd can peek at the socket credentials to match the user in the config file.
lowkey important: while this works great for TCP sockets, it cannot be relied on for unbound UDP sockets. it's also less meaningful when it comes to connections using non-privileged ports. on the other hand, if a request comes in that has a local endpoint indicating a UDP privileged port, we can presume the client was privileged enough to acquire that port. iykyk.
once an entry matches, blacklistd can do a bunch of different actions. if the action is βaddβ and the number-of-tries limit is reached, 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 blacklistd). the script could print a numerical id to stdout as a handle for the rule, so it can be used later to remove that connection β but that's not required, because all the info needed to remove the rule is kept anyway. π
if the action is βremβ, then the same control script gets invoked as:
control rem <rulename> <proto> <address> <mask> <port> <id>
where id is the number returned from the βaddβ action.
blacklistd keeps a whole lil database of known connections in dbfile. on startup it reads entries from that file and updates its internal state. π
blacklistd checks the list of active entries every timeout seconds (default 15) and removes entries and block rules using the control program as needed.
the following options are available:
π OPTIONS π
-Ccontrolprog β use controlprog to communicate with the packet filter instead of the default, which is/usr/libexec/blacklistd-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 address.
- port β the optional numeric port to be blocked (can be empty).
- id β for packet filters that support removal of rules by rule identifier, the identifier of the rule to be removed. the
addcommand is expected to return the rule identifier string to stdout.
- action β the action to perform:
-cconfiguration β the name of the configuration file to read. the default when-cisn't given is/etc/blacklistd.conf.-Ddbfile β the Berkeley DB file whereblacklistdstores its state. defaults to/var/db/blocklistd.db.-dβ normallyblacklistddisassociates itself from the terminal, unless the-dflag is specified, in which case it stays in the foreground. main character energy, honestly.-fβ truncate the state database and flush all the rules named rulename are deleted by invoking the control script as:
control flush <rulename>
-Psockpathsfile β a file containing a list of pathnames, one per line, thatblacklistdwill create sockets to listen to. this is useful for chrooted environments. π₯-Rrulename β specify the default rule name for the packet filter rules, usuallyblacklistd.-rβ re-read the firewall rules from the internal database, then remove and re-add them. this helps for packet filters that don't retain state across reboots. π¦-ssockpath β add sockpath to the list of Unix socketsblacklistdlistens to.-ttimeout β the interval in secondsblacklistdpolls the state file to update the rules.-vβ causeblacklistdto print diagnostic messages to stdout instead ofsyslogd(8).
β SIGNAL HANDLING β
blacklistd deals with the following signals:
HUPβ receipt of this signal causesblacklistdto re-read the configuration file.INT,TERM&QUITβ these signals tellblacklistdto exit in an orderly fashion. say bye nicely bestie πUSR1β this signal tellsblacklistdto increase the internal debugging level by1.USR2β this signal tellsblacklistdto decrease the internal debugging level by1.
π§ FILES π§
/usr/libexec/blacklistd-helperβ shell script invoked to interface with the packet filter./etc/blacklistd.confβ configuration file./var/db/blocklistd.dbβ database of current connection entries./var/run/blocklistd.sockβ socket to receive connection notifications.
π SEE ALSO π
blacklistd.conf(5), blacklistctl(8), ipf(8), ipfw(8), pfctl(8), syslogd(8)
π NOTES π
the blacklistd daemon has been renamed to blocklistd(8). periodt. β¨
πΈ HISTORY πΈ
blacklistd first appeared in NetBSD 7. FreeBSD support for blacklistd was implemented in FreeBSD 11.
π AUTHORS π
Christos Zoulas
okay that's the whole page π«Ά this one's from Debian, dated February 25, 2025 β and honestly? iconic of them. go block some ports responsibly, bestie ππ
π¦ 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