Wesbytes Knowledge Base

Search our articles or browse by category below

Setting Up a Firewall For Linux VPS Server

Last modified: June 17, 2022
You are here:
Estimated reading time: 1 min
Linux VPS Server

When it comes to installing and configuring a firewall for VPS, regardless of it is Linux-based or Windows-based, root access to the server is usually required. It is unavoidable as the firewall is essential for a VPS and this process requires some command-line work, which some weren’t familiar with it.

The following steps are guides to help you set up a firewall on your Linux VPS server. The firewall we will be using for this guide is the CSF or ConfigServer Firewall.

Step 1: Download CSF

Before downloading, locate to the usr/src directory using the following command.

cd /usr/src/

After using the cd command to locate the usr/src directory, download the CSF archive using the wget command as followed.

wget https://download.configserver.com/csf.tgz

The latest version of CSF will be downloaded into the /usr/src directory of your VPS through the official page after running the command.

Step 2: Extract the downloaded archive

To extract the downloaded CSF archive, run the following command.

tar xzf csf.tgz

A new directory named “csf” will be created.

Step 3: Installation

To run the installer, first, you will need to go to the csf directory using the cd command.

cd csf

To run the installer that is located in the csf directory, run the following command.

sh install.sh

If there is an error during installation, it is likely due to the lack of prerequisites. In the case where you don’t have both Perl and libwww installed in your Linux distribution. Here are the commands you can use to install both Perl and libwww.

For the case of installing RHEL-based distribution, use this command.

yum install perl-libwww-perl

Step 4: Configuration

Finally, for the configuration, all existing firewall needs to be disabled first before you can start configuring CSF. To disable them, use the systemctl command. CSF configuration file can be found at /etc/csf/csf.conf. You can also easily enable and manage your firewall if you are using a web hosting control panel.

Many firewalls, including CSF, come with documentation. Please look out for them to figure out what settings do you need to set up in your firewall. Refer through the documentation too if you are using another firewall that isn’t CSF as the command can be slightly different.

Was this article helpful?
Dislike 0
Views: 22