Skip to content

Commit 8f20bb7

Browse files
committed
handbook/firewalls: Adapt blacklistd to blocklistd
Follow upstream rename from blacklistd to blocklistd, and adapt the documentation accordingly.
1 parent ca3aaca commit 8f20bb7

File tree

1 file changed

+54
-54
lines changed
  • documentation/content/en/books/handbook/firewalls

1 file changed

+54
-54
lines changed

documentation/content/en/books/handbook/firewalls/_index.adoc

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ part: IV. Network Communication
44
prev: books/handbook/network-servers
55
next: books/handbook/advanced-networking
66
description: "FreeBSD has three firewalls built into the base system: PF, IPFW, and IPFILTER. This chapter covers how to define packet filtering rules, the differences between the firewalls built into FreeBSD and how to use them"
7-
tags: ["firewall", "pf", "ipfw", "ipfilter", "blacklistd", "filtering"]
7+
tags: ["firewall", "pf", "ipfw", "ipfilter", "blocklistd", "filtering"]
88
showBookMenu: true
99
weight: 38
1010
params:
@@ -2451,48 +2451,48 @@ Refer to man:ipf[5] for a list of letters and their flags.
24512451
If the packet is an ICMP packet, there will be two fields at the end: the first always being "icmp" and the next being the ICMP message and sub-message type, separated by a slash.
24522452
For example: `icmp 3/3` for a port unreachable message.
24532453

2454-
[[firewalls-blacklistd]]
2455-
== Blacklistd
2454+
[[firewalls-blocklistd]]
2455+
== Blocklistd
24562456

2457-
Blacklistd is a daemon listening to sockets awaiting to receive notifications from other daemons about connection attempts that failed or were successful.
2457+
Blocklistd is a daemon listening to sockets awaiting to receive notifications from other daemons about connection attempts that failed or were successful.
24582458
It is most widely used in blocking too many connection attempts on open ports.
24592459
A prime example is SSH running on the internet getting a lot of requests from bots or scripts trying to guess passwords and gain access.
2460-
Using blacklistd, the daemon can notify the firewall to create a filter rule to block excessive connection attempts from a single source after a number of tries. Blacklistd was first developed on NetBSD and appeared there in version 7.
2461-
FreeBSD 11 imported blacklistd from NetBSD.
2460+
Using blocklistd, the daemon can notify the firewall to create a filter rule to block excessive connection attempts from a single source after a number of tries. Blocklistd was first developed on NetBSD and appeared there in version 7, it was originally called blacklistd.
2461+
FreeBSD 11 imported blocklistd from NetBSD.
24622462

2463-
This chapter describes how to set up blacklistd, configure it, and provides examples on how to use it.
2463+
This chapter describes how to set up blocklistd, configure it, and provides examples on how to use it.
24642464
Readers should be familiar with basic firewall concepts like rules.
24652465
For details, refer to the firewall chapter.
2466-
PF is used in the examples, but other firewalls available on FreeBSD should be able to work with blacklistd, too.
2466+
PF is used in the examples, but other firewalls available on FreeBSD should be able to work with blocklistd, too.
24672467

2468-
=== Enabling Blacklistd
2468+
=== Enabling Blocklistd
24692469

2470-
The main configuration for blacklistd is stored in man:blacklistd.conf[5].
2471-
Various command line options are also available to change blacklistd's run-time behavior.
2472-
Persistent configuration across reboots should be stored in [.filename]#/etc/blacklistd.conf#.
2473-
To enable the daemon during system boot, add a `blacklistd_enable` line to [.filename]#/etc/rc.conf# like this:
2470+
The main configuration for blocklistd is stored in man:blocklistd.conf[5].
2471+
Various command line options are also available to change blocklistd's run-time behavior.
2472+
Persistent configuration across reboots should be stored in [.filename]#/etc/blocklistd.conf#.
2473+
To enable the daemon during system boot, add a `blocklistd_enable` line to [.filename]#/etc/rc.conf# like this:
24742474

24752475
[source,shell]
24762476
....
2477-
# sysrc blacklistd_enable=yes
2477+
# sysrc blocklistd_enable=yes
24782478
....
24792479

24802480
To start the service manually, run this command:
24812481

24822482
[source,shell]
24832483
....
2484-
# service blacklistd start
2484+
# service blocklistd start
24852485
....
24862486

2487-
=== Creating a Blacklistd Ruleset
2487+
=== Creating a Blocklistd Ruleset
24882488

2489-
Rules for blacklistd are configured in man:blacklistd.conf[5] with one entry per line.
2489+
Rules for blocklistd are configured in man:blocklistd.conf[5] with one entry per line.
24902490
Each rule contains a tuple separated by spaces or tabs.
2491-
Rules either belong to a `local` or a `remote`, which applies to the machine where blacklistd is running or an outside source, respectively.
2491+
Rules either belong to a `local` or a `remote`, which applies to the machine where blocklistd is running or an outside source, respectively.
24922492

24932493
==== Local Rules
24942494

2495-
An example blacklistd.conf entry for a local rule looks like this:
2495+
An example blocklistd.conf entry for a local rule looks like this:
24962496

24972497
[.programlisting]
24982498
....
@@ -2505,7 +2505,7 @@ When a `[remote]` section is encountered, all rules that follow it are handled a
25052505

25062506
Seven fields separated by either tabs or spaces define a rule.
25072507
The first four fields identify the traffic that should be blocklisted.
2508-
The three fields that follow define backlistd's behavior.
2508+
The three fields that follow define blocklistd's behavior.
25092509
Wildcards are denoted as asterisks (`*`), matching anything in this field.
25102510
The first field defines the location.
25112511
In local rules, these are the network ports.
@@ -2523,19 +2523,19 @@ The socket type is defined by the second field.
25232523
TCP sockets are of type `stream`, whereas UDP is denoted as `dgram`.
25242524
The example above uses TCP, since SSH is using that protocol.
25252525

2526-
A protocol can be used in the third field of a blacklistd rule.
2526+
A protocol can be used in the third field of a blocklistd rule.
25272527
The following protocols can be used: `tcp`, `udp`, `tcp6`, `udp6`, or numeric.
25282528
A wildcard, like in the example, is typically used to match all protocols unless there is a reason to distinguish traffic by a certain protocol.
25292529

25302530
In the fourth field, the effective user or owner of the daemon process that is reporting the event is defined.
25312531
The username or UID can be used here, as well as a wildcard (see example rule above).
25322532

25332533
The packet filter rule name is declared by the fifth field, which starts the behavior part of the rule.
2534-
By default, blacklistd puts all blocks under a pf anchor called `blacklistd` in [.filename]#pf.conf# like this:
2534+
By default, blocklistd puts all blocks under a pf anchor called `blocklistd` in [.filename]#pf.conf# like this:
25352535

25362536
[.programlisting]
25372537
....
2538-
anchor "blacklistd/*" in on $ext_if
2538+
anchor "blocklistd/*" in on $ext_if
25392539
block in
25402540
pass out
25412541
....
@@ -2550,7 +2550,7 @@ A modified example from the above using the hyphen would look like this:
25502550
ssh stream * * -ssh 3 24h
25512551
....
25522552

2553-
With such a rule, any new blocklist rules are added to an anchor called `blacklistd-ssh`.
2553+
With such a rule, any new blocklist rules are added to an anchor called `blocklistd-ssh`.
25542554

25552555
To block whole subnets for a single rule violation, a `/` in the rule name can be used.
25562556
This causes the remaining portion of the name to be interpreted as the mask to be applied to the address specified in the rule.
@@ -2573,18 +2573,18 @@ The sixth field, called `nfail`, sets the number of login failures required to b
25732573
When a wildcard is used at this position, it means that blocks will never happen.
25742574
In the example rule above, a limit of three is defined meaning that after three attempts to log into SSH on one connection, the IP is blocked.
25752575

2576-
The last field in a blacklistd rule definition specifies how long a host is blocklisted.
2576+
The last field in a blocklistd rule definition specifies how long a host is blocklisted.
25772577
The default unit is seconds, but suffixes like `m`, `h`, and `d` can also be specified for minutes, hours, and days, respectively.
25782578

25792579
The example rule in its entirety means that after three times authenticating to SSH will result in a new PF block rule for that host.
25802580
Rule matches are performed by first checking local rules one after another, from most specific to least specific.
2581-
When a match occurs, the `remote` rules are applied and the name, `nfail`, and disable fields are changed by the `remote` rule that matched.
2581+
When a match occurs, the `remote` rules are applied and the `name`, `nfail`, and `duration` fields are changed by the `remote` rule that matched.
25822582

25832583
==== Remote Rules
25842584

2585-
Remote rules are used to specify how blacklistd changes its behavior depending on the remote host currently being evaluated.
2585+
Remote rules are used to specify how blocklistd changes its behavior depending on the remote host currently being evaluated.
25862586
Each field in a remote rule is the same as in a local rule.
2587-
The only difference is in the way blacklistd is using them.
2587+
The only difference is in the way blocklistd is using them.
25882588
To explain it, this example rule is used:
25892589

25902590
[.programlisting]
@@ -2597,10 +2597,10 @@ The address field can be an IP address (either v4 or v6), a port or both.
25972597
This allows setting special rules for a specific remote address range like in this example.
25982598
The fields for socket type, protocol and owner are identically interpreted as in the local rule.
25992599

2600-
The name fields is different though: the equal sign (`=`) in a remote rule tells blacklistd to use the value from the matching local rule.
2600+
The name fields is different though: the equal sign (`=`) in a remote rule tells blocklistd to use the value from the matching local rule.
26012601
It means that the firewall rule entry is taken and the `/25` prefix (a netmask of `255.255.255.128`) is added.
26022602
When a connection from that address range is blocklisted, the entire subnet is affected.
2603-
A PF anchor name can also be used here, in which case blacklistd will add rules for this address block to the anchor of that name.
2603+
A PF anchor name can also be used here, in which case blocklistd will add rules for this address block to the anchor of that name.
26042604
The default table is used when a wildcard is specified.
26052605

26062606
A custom number of failures in the `nfail` column can be defined for an address.
@@ -2609,72 +2609,72 @@ Blocking is disabled when an asterisk is used in this sixth field.
26092609

26102610
Remote rules allow a stricter enforcement of limits on attempts to log in compared to attempts coming from a local network like an office.
26112611

2612-
=== Blacklistd Client Configuration
2612+
=== Blocklistd Client Configuration
26132613

2614-
There are a few software packages in FreeBSD that can utilize blacklistd's functionality.
2614+
There are a few software packages in FreeBSD that can utilize blocklistd's functionality.
26152615
The two most prominent ones are man:ftpd[8] and man:sshd[8] to block excessive connection attempts.
2616-
To activate blacklistd in the SSH daemon, add the following line to [.filename]#/etc/ssh/sshd_config#:
2616+
To activate blocklistd in the SSH daemon, add the following line to [.filename]#/etc/ssh/sshd_config#:
26172617

26182618
[.programlisting]
26192619
....
2620-
UseBlacklist yes
2620+
UseBlocklist yes
26212621
....
26222622

26232623
Restart sshd afterwards to make these changes take effect.
26242624

2625-
Blacklisting for man:ftpd[8] is enabled using `-B`, either in [.filename]#/etc/inetd.conf# or as a flag in [.filename]#/etc/rc.conf# like this:
2625+
Blocklisting for man:ftpd[8] is enabled using `-B`, either in [.filename]#/etc/inetd.conf# or as a flag in [.filename]#/etc/rc.conf# like this:
26262626

26272627
[.programlisting]
26282628
....
26292629
ftpd_flags="-B"
26302630
....
26312631

2632-
That is all that is needed to make these programs talk to blacklistd.
2632+
That is all that is needed to make these programs talk to blocklistd.
26332633

2634-
=== Blacklistd Management
2634+
=== Blocklistd Management
26352635

2636-
Blacklistd provides the user with a management utility called man:blacklistctl[8].
2637-
It displays blocked addresses and networks that are blocklisted by the rules defined in man:blacklistd.conf[5].
2636+
Blocklistd provides the user with a management utility called man:blocklistctl[8].
2637+
It displays blocked addresses and networks that are blocklisted by the rules defined in man:blocklistd.conf[5].
26382638
To see the list of currently blocked hosts, use `dump` combined with `-b` like this.
26392639

26402640
[source,shell]
26412641
....
2642-
# blacklistctl dump -b
2643-
address/ma:port id nfail last access
2644-
213.0.123.128/25:22 OK 6/3 2019/06/08 14:30:19
2642+
# blocklistctl dump -b
2643+
rulename address/ma:port id nfail last access
2644+
blocklistd 213.0.123.128/25:22 OK 6/3 2019/06/08 14:30:19
26452645
....
26462646

26472647
This example shows that there were 6 out of three permitted attempts on port 22 coming from the address range `213.0.123.128/25`.
26482648
There are more attempts listed than are allowed because SSH allows a client to try multiple logins on a single TCP connection.
2649-
A connection that is currently going on is not stopped by blacklistd.
2649+
A connection that is currently going on is not stopped by blocklistd.
26502650
The last connection attempt is listed in the `last access` column of the output.
26512651

26522652
To see the remaining time that this host will be on the blocklist, add `-r` to the previous command.
26532653

26542654
[source,shell]
26552655
....
2656-
# blacklistctl dump -br
2657-
address/ma:port id nfail remaining time
2658-
213.0.123.128/25:22 OK 6/3 36s
2656+
# blocklistctl dump -br
2657+
rulename address/ma:port id nfail remaining time
2658+
blocklistd 213.0.123.128/25:22 OK 6/3 36s
26592659
....
26602660

26612661
In this example, there are 36s seconds left until this host will not be blocked any more.
26622662

26632663
=== Removing Hosts from the Block List
26642664

26652665
Sometimes it is necessary to remove a host from the block list before the remaining time expires.
2666-
Unfortunately, there is no functionality in blacklistd to do that.
2666+
Unfortunately, there is no functionality in blocklistd to do that.
26672667
However, it is possible to remove the address from the PF table using pfctl.
2668-
For each blocked port, there is a child anchor inside the blacklistd anchor defined in [.filename]#/etc/pf.conf#.
2669-
For example, if there is a child anchor for blocking port 22 it is called `blacklistd/22`.
2668+
For each blocked port, there is a child anchor inside the blocklistd anchor defined in [.filename]#/etc/pf.conf#.
2669+
For example, if there is a child anchor for blocking port 22 it is called `blocklistd/22`.
26702670
There is a table inside that child anchor that contains the blocked addresses.
26712671
This table is called port followed by the port number.
26722672
In this example, it would be called `port22`.
26732673
With that information at hand, it is now possible to use man:pfctl[8] to display all addresses listed like this:
26742674

26752675
[source,shell]
26762676
....
2677-
# pfctl -a blacklistd/22 -t port22 -T show
2677+
# pfctl -a blocklistd/22 -t port22 -T show
26782678
...
26792679
213.0.123.128/25
26802680
...
@@ -2684,9 +2684,9 @@ After identifying the address to be unblocked from the list, the following comma
26842684

26852685
[source,shell]
26862686
....
2687-
# pfctl -a blacklistd/22 -t port22 -T delete 213.0.123.128/25
2687+
# pfctl -a blocklistd/22 -t port22 -T delete 213.0.123.128/25
26882688
....
26892689

2690-
The address is now removed from PF, but will still show up in the blacklistctl list, since it does not know about any changes made in PF.
2691-
The entry in blacklistd's database will eventually expire and be removed from its output.
2692-
The entry will be added again if the host is matching one of the block rules in blacklistd again.
2690+
The address is now removed from PF, but will still show up in the blocklistctl list, since it does not know about any changes made in PF.
2691+
The entry in blocklistd's database will eventually expire and be removed from its output.
2692+
The entry will be added again if the host is matching one of the block rules in blocklistd again.

0 commit comments

Comments
 (0)