How to Install CSF on Ubuntu 22.04
Config Server Firewall is a free and advanced firewall for most Linux distributions and Linux based VPS. It provides a comprehensive set of tools to protect your system, including advanced firewall rules, intrusion detection, and login failure detection.
Pre-requisites
-
A system with Ubuntu 22.04 installed and running.
- root access to the system.
Update the System
Run the below command to ensure your system is up-to-date,
apt update -y
apt upgrade -y
Install required packages
CSF requires some Perl modules to work correctly. Install them using the below command,
apt install -y libwww-perl libcrypt-ssleay-perl libio-socket-ssl-perl
Download and install CSF
Next download and install CSF. The below commands will retrieve the latest version of CSF, extract it, and start the installation,
cd /tmp
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf
sudo ./install.sh
Configure CSF
Once CSF is installed, you can configure it to your needs. The main configuration file for CSF is located at /etc/csf/csf.conf
.
You can use any text editor to modify it, in our case we are using nano editing,
nano /etc/csf/csf.conf
In this file, you can make any changes like ports are open, in our case we'll remove SSH port from CSF,
Remove the 22
from TCP_IN
as below,
# Allow incoming TCP ports
TCP_IN = "20,21,22,25,53,80,110,143,443,465,587,853,993,995,2077,2078,2079,2080,2082,2083,2086,2087,2095,2096,8443"
Allow outgoing TCP ports
TCP_OUT = "20,21,22,25,37,43,53,80,110,113,443,587,853,873,993,995,2086,2087,2089,2703"
#### Start CSF
After configuring CSF, start the firewall using the following command:
csf -s
Use the below command to reload the CSF,
csf -ra
If everything is working correctly, you can enable CSF and put it into active mode using below command,
csf -e
That's it! You have now installed and configured CSF on Ubuntu 22.04
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS