• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Sunday, May 11, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System BSD

How to Install Blacklistd on FreeBSD 11.1

How VPS by How VPS
September 1, 2019
in BSD
0
0
SHARES
37
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Introduction
  2. Step 1: PF (Firewall)
  3. Step 2: Blacklistd
  4. Step 3: SSH
  5. Final step
  6. Want to contribute?


Introduction

Any service that is connected to the internet is a potential target for brute-force attacks or unwarranted access. There are tools like fail2ban or sshguard, but these are functionally limited because they are only parsing log files. Blacklistd takes a different approach. Modified daemons like SSH are able to connect directly to blacklistd to add new firewall rules.

Step 1: PF (Firewall)

An anchor is a collection of rules and we need one in our PF configuration. To create a minimal ruleset, edit /etc/pf.conf so it looks like this:

set skip on lo0
scrub in on vtnet0 all fragment reassemble

anchor "blacklistd/*" in on vtnet0

block in all
pass out all keep state
antispoof for vtnet0 inet

pass in quick on vtnet0 inet proto icmp all icmp-type echoreq
pass in quick on vtnet0 proto tcp from any to vtnet0 port 22

Now enable PF to start automatically, edit /etc/rc.conf:

pf_enable="YES"
pf_rules="/etc/pf.conf"
pflog_enable="YES"
pflog_logfile="/var/log/pflog"

However, there is one additional thing you might want to do first: test your rules to be sure everything is correct. For this, use the following command:

pfctl -vnf /etc/pf.conf

If this command reports errors, go back and fix those first!

It is a good idea to make sure everything is working as expected by rebooting the server now: shutdown -r now

Step 2: Blacklistd

IP’s are blocked for 24h. This is the default value and can be changed in /etc/blacklistd:

# Blacklist rule
# adr/mask:port type    proto   owner           name    nfail   disable
[local]
ssh             stream  *       *               *       3       24h

Edit /etc/rc.conf to enable Blacklistd:

blacklistd_enable="YES"
blacklistd_flags="-r"

Start Blacklistd with the following command:

service blacklistd start

Step 3: SSH

One last thing we need to do is tell sshd to notify blacklistd. Add UseBlacklist yes to your /etc/ssh/sshd_config file. Now restart SSH with service sshd restart.

Final step

Finally, try logging into your server with an invalid password.

To get all of the blocked IPs use one of the following commands:

blacklistctl dump -bw
        address/ma:port id      nfail   last access
 150.x.x.x/32:22        OK      3/3     2017/x/x 04:43:03
 115.x.x.x/32:22        OK      3/3     2017/x/x 04:45:40
  91.x.x.x/32:22        OK      3/3     2017/x/x 07:51:16
  54.x.x.x/32:22        OK      3/3     2017/x/x 12:05:57

pfctl -a blacklistd/22 -t port22 -T show
   54.x.x.x
   91.x.x.x
  115.x.x.x
  150.x.x.x

To remove a blocked IP you must use the command pfctl. For example:

pfctl -a blacklistd/22 -t port22 -T delete <IP>

Note that blacklistctl will still show the IP as blocked! This is normal behavior and will hopefully be removed in future releases.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

How to Install Omeka Classic 2.4 CMS on a FreeBSD 11 FAMP VPS

Next Post

How to Install DokuWiki on FreeBSD 12

Next Post

How to Install DokuWiki on FreeBSD 12

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet