如何在CentOS 7上安装CSF防火墙
CSF代表ConfigServer安全性,防火墙是Linux操作系统最有用的开源安全应用程序,该系统用作Linux服务器的数据包检查防火墙,登录和入侵检测。
使用CSF有助于保护服务器免受许多安全攻击,例如暴力攻击。
它配备了一个名为(LFD)登录失败守护程序的服务,该守护程序可防止未经授权访问网络守护进程,以便为过多的登录失败监视我们想要限制IP地址访问的过多登录失败,有助于防止访问泄露网络守护进程。
因此,每当来自特定IP的大量错误尝试时,那么IP将立即从服务器上的所有服务暂时阻止。
ConfigServer Security&Firewall包含很多功能,可提供SSH登录通知,过度连接阻止,Mod_security失败,可疑过程报告和许多其他功能。
1)准备工作
CSF可以安装在本教程中的任何Linux发行版上,我们将使用CentOS 7.1安装和配置它。
使用root用户登录CentOS 7服务器,并确保我们已连接到Internet以更新系统,并使用最新更新,并为CSF安装所需的相关包。
登录后,运行以下命令进行系统更新。
# yum update
然后安装在CentOS上设置CSF所需的Perl模块,请执行以下命令。
# yum -y install perl perl-libwww-perl perl-LWP-Protocol-https perl-GDGraph wget unzip net-tools
2)下载CSF安装包
要下载ConfigServer Security&Firewall软件包,请在/usr/src /目录中运行以下命令,如图所示。
# wget https://download.configserver.com/csf.tgz
下载accived包后,运行以下命令以在同一目录中提取它。
# tar -xzf csf.tgz
现在将目录更改为提取的文件夹,并使用LIST命令查看其内部配置和安装脚本,如图所示。
3)安装ConfigServer安全防火墙
要在CentOS 7上开始安装CSF,我们将运行在同一目录中存在的安装脚本,如上所示。
让我们如图所示运行以下命令。
# sh install.sh
安装脚本将检查其基本Perl模块和root Access,然后在安装过程中创建一个数字目录并编译不同的配置文件和库,如下所示。
*** USE_CONNTRACK Enabled *** IPV6 Enabled *** IPV6_SPI set to 1 TCP ports currently listening for incoming connections: 22,5432 UDP ports currently listening for incoming connections: 5353,43539 Note: The port details above are for information only, csf hasn't been auto-configured. Don't forget to: 1. Configure the following options in the csf configuration to suite your server: TCP_*, UDP_* 2. Restart csf and lfd 3. Set TESTING to 0 once you're happy with the firewall, lfd will not run until you do so Adding current SSH session IP address to the csf whitelist in csf.allow: Adding 172.xx.xx.xx to csf.allow only while in TESTING mode (not iptables ACCEPT) *WARNING* TESTING mode is enabled - do not forget to disable it in the configuration ‘lfd.service’ -> ‘/usr/lib/systemd/system/lfd.service’ ‘csf.service’ -> ‘/usr/lib/systemd/system/csf.service’ ln -s '/usr/lib/systemd/system/csf.service' '/etc/systemd/system/multi-user.target.wants/csf.service' ln -s '/usr/lib/systemd/system/lfd.service' '/etc/systemd/system/multi-user.target.wants/lfd.service' ‘/etc/csf/csfwebmin.tgz’ -> ‘/usr/local/csf/csfwebmin.tgz’ Installation Completed
我们可以看到在安装过程完成之前,CSF自动配置已在安装上的SSH端口的已侦听端口,然后自动白白选项在可能安装的连接IP地址。
4)测试CSF IPTABLE模块
安装过程完成后,请运行以下命令以测试所需的iptables模块的状态。
# perl /usr/local/csf/bin/csftest.pl
5)CSF配置和使用
要在CentOS 7和其他Red Hat Enterprise Linux(RHEL)的发行版上配置CSF防火墙,默认配置文件可以在"/etc/csf /"的位置找到
配置文件包括如图所示的以下文件数。
要启用全功能CSF防火墙,请使用以下参数配置默认的CSF配置文件。
[root@centos-7 csf]# vim csf.conf TESTING = "0" :wq!
现在,我们将通过制作以下配置更改,指定电子邮件地址以报告登录失败守护程序的错误。
在进行配置更改后,我们必须使用以下命令重新加载CSF服务,以便配置更改可能会生效。
# csf -r
如果要检查CSF服务的状态,则运行以下命令。
# service csf status
运行以下命令以完成使用CSF使用CAN的所有命令行选项的概述。
# csf --help