在Ubuntu 20.04 LTS Focal Fossa上安装Fail2ban
步骤1.首先,通过apt
在终端中运行以下以下命令,确保所有系统软件包都是最新的。
sudo apt update
sudo apt upgrade
步骤2.在Ubuntu 20.04上安装Fail2ban。
运行以下命令以安装Fail2ban:
sudo apt install fail2ban
完成后,Fail2ban服务将自动启动。您可以使用以下命令验证Fail2ban:
sudo systemctl status fail2ban
步骤3. Fail2ban配置。
默认的fail2ban安装带有两个配置文件,并且您可以了解更多关于fail2ban这里。要开始配置Fail2ban服务器打开,请使用nano编辑器打开jail.local文件:/etc/fail2ban/jail.conf
/etc/fail2ban/jail.d/defaults-debian.conf
[DEFAULT] # "ignoreip" can be an IP address, a CIDR mask or a DNS host. Fail2ban will not # ban a host which matches an address in this list. Several addresses can be # defined using space separator. ignoreip = 127.0.0.1/8 ::1 123.123.123.123 192.168.1.0/24 # "bantime" is the number of seconds that a host is banned. bantime = 2d # A host is banned if it has generated "maxretry" during the last "findtime" # seconds. findtime = 600 maxretry = 5 # Destination email address used solely for the interpolations in # jail.{conf,local} configuration files. destemail = admin@yundongfang.com sender = root@yundongfang.com
重新启动Fail2ban服务以使更改生效:
sudo systemctl restart fail2ban
恭喜你!您已经成功安装了Fail2Ban。感谢您使用本教程在Linux Ubuntu系统上安装Fail2Ban。有关其他帮助或有用信息,我们建议您检查Fail2Ban官方网站。
原创文章,作者:校长,如若转载,请注明出处:https://www.yundongfang.com/Yun41315.html