How to install the ConfigServer and Security Firewall combo on Ubuntu Server

If you would like a strong firewall in your Ubuntu Server, however one that provides a reasonably easy configuration, Jack Wallen thinks CSF is perhaps the fitting instrument for the job.


Illustration: Lisa Hornung/TechRepublic

Though Uncomplicated Firewall is an impressive safety service on Ubuntu Server, there is perhaps occasions while you want extra. But when you do not have the time (or the inclination) to study the extremely advanced iptables, you may want an choice that lies someplace in between. Such an choice is the ConfigServer/Safety Firewall mixture, which presents a stable firewall answer that may be expanded with add-ons for issues comparable to login/intrusion detection, exploit checks, ping of dying safety, and extra.

I am going to stroll you thru the set up of CSF on Ubuntu Server 20.04.

SEE: Password breach: Why popular culture and passwords do not combine (free PDF) (TechRepublic)

What you will want

To be able to set up CSF, you will want a operating occasion of Ubuntu Server and a consumer with sudo privileges. That is it. Let’s dive in.

How one can set up ConfigServer on Ubuntu Server 20.04

The very first thing to be finished is to put in the mandatory dependencies. Log into your Ubuntu Server and concern the command:

sudo apt set up wget libio-socket-ssl-perl git perl iptables libnet-libidn-perl libcrypt-ssleay-perl  libio-socket-inet6-perl libsocket6-perl sendmail dnsutils unzip -y

When that command completes, obtain the most recent model of CSF with the command:


Unpack that newly downloaded tar file with:

tar -xvfz csf.tgz

Develop into the newly created listing with:

cd csf

Set up CSF by operating the included script with:

sudo bash set

Earlier than we proceed on, let’s be sure iptables is loaded with:

sudo perl /usr/native/csf/bin/

You need to see:

Testing ip_tables/iptable_filter...OK
Testing ipt_LOG...OK
Testing ipt_multiport/xt_multiport...OK
Testing ipt_REJECT...OK
Testing ipt_state/xt_state...OK
Testing ipt_limit/xt_limit...OK
Testing ipt_recent...OK
Testing xt_connlimit...OK
Testing ipt_owner/xt_owner...OK
Testing iptable_nat/ipt_REDIRECT...OK
Testing iptable_nat/ipt_DNAT...OK

RESULT: csf ought to perform on this server

How one can configure CSF on Ubuntu Server 20.04

We’re able to configure CSF. Open the configuration file with:

sudo nano /and many others/csf/csf.conf

The very first thing we should do is change the road:




Subsequent, we have to prohibit rsyslog/syslog entry to members of a selected group. For this, find the road:


Change that line to:


Now comes the enjoyable half. Scroll down till you see the road beginning with:


That is the place you may configure ports to be allowed by the firewall. By default CSF will permit ports 20, 21, 22, 25, 53, 80, 110, 143, 443, 465, 587, 993 and 995. Change that line to solely the ports you want open for the server in query.

Subsequent, discover the strains beginning with TCP_OUT, UDP_IN, and UDP_OUT and do the identical factor (configuring solely the ports you need open for incoming and outgoing site visitors).

As soon as you have accomplished that process, save and shut the file. 

Begin and allow CSF with the command:

sudo systemctl allow --now csf

How one can block and permit IP addresses with CSF

This is among the methods CSF stands out among the many competitors. Let me present you the way straightforward it’s to dam or permit an IP tackle. To dam an IP tackle, open the deny file with:

sudo nano /and many others/csf/csf.deny

On the backside of that file, add the IP addresses you wish to block (one per line), like so:

You can too block a whole subnet like this:

To permit an IP tackle, open the permit file with:

sudo nano /and many others/csf/csf.permit

In that file, add the IP addresses or subnets (in the identical method you probably did for deny) after which save the file.

Lastly, you may set CSF to exclude an IP tackle within the csf.ignore file (which is configured in the identical method you configured the deny and permit information).

And that is all there’s to putting in and configuring the ConfigServer Safety Firewall mixture on Ubuntu Server. In the event you’re searching for a strong, but easy, firewall in your servers, this is perhaps precisely what you are searching for.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the most recent tech recommendation for enterprise professionals from Jack Wallen.

Additionally see

Recent Articles


Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox