{"id":11301,"date":"2021-10-29T10:08:46","date_gmt":"2021-10-29T10:08:46","guid":{"rendered":"https:\/\/linuxways.net\/?p=11301"},"modified":"2021-10-29T10:08:46","modified_gmt":"2021-10-29T10:08:46","slug":"how-to-install-and-configure-csfconfig-server-firewall-on-ubuntu-20-04-lts","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-install-and-configure-csfconfig-server-firewall-on-ubuntu-20-04-lts\/","title":{"rendered":"How to Install and Configure CSF(Config Server Firewall) on Ubuntu 20.04 LTS"},"content":{"rendered":"<p>Config Server Firewall (CSF) is a free and open-source firewall that is used to protect Linux servers from unauthenticated users. Services such as SSH, SMTP, HTTP, IMAP, POP3, and FTP as well as many other protocols, are continuously monitored by CSF.<\/p>\n<p>This firewall allows you to temporarily or permanently block and unblock specified IP addresses. It also has a web-based interface for cPanel, Webmin, and DirectAdmin that allows you to manage your firewall from a web browser.<\/p>\n<p>CSF is very simple and straightforward to install. This guide will walk you through the process of installing and Configuring the Config Server Firewall on Ubuntu 20.04.<\/p>\n<h2><strong>Step 1: Remove UFW firewall<\/strong><\/h2>\n<p>By default, Ubuntu comes with the UFW firewall already installed. The first thing that you would want to do is to remove it before installing the CSF firewall. Therefore, run the command:<\/p>\n<pre><strong>$ sudo apt remove ufw<\/strong><\/pre>\n<h2><strong>Step 2: Install Required Dependencies<\/strong><\/h2>\n<p>CSF Web comes with a web interface based on perl that requires some dependencies installed. Install the required dependencies as shown:<\/p>\n<pre><strong>$ sudo apt-get install sendmail dnsutils unzip git perl iptables libio-socket-ssl-perl libcrypt-ssleay-perl libnet-libidn-perl libio-socket-inet6-perl libsocket6-perl -y<\/strong><\/pre>\n<h2><strong>Step 3: Download Config Server Firewall(CSF)<\/strong><\/h2>\n<p>Download the CSF archive file from its <a href=\"https:\/\/configserver.com\/cp\/csf.html\">official site<\/a> since it is not available in Ubuntu repositories. Run the following wget command to download CSF.<\/p>\n<pre><strong>$ sudo wget <\/strong><a href=\"http:\/\/download.configserver.com\/csf.tgz\"><strong>http:\/\/download.configserver.com\/csf.tgz<\/strong><\/a><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"1152\" height=\"234\" class=\"wp-image-11302\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-376.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-376.png 1152w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-376-300x61.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-376-1024x208.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-376-768x156.png 768w\" sizes=\"auto, (max-width: 1152px) 100vw, 1152px\" \/><\/strong><\/p>\n<p>Once the download is complete, extract the archive file as shown:<\/p>\n<pre><strong>$ tar -xvzf csf.tgz<\/strong><\/pre>\n<h2><strong>Step 4: Install Config Server Firewall(CSF)<\/strong><\/h2>\n<p>Next, navigate into the CSF directory and install it by running the following script:<\/p>\n<pre><strong>$ cd csf<\/strong><\/pre>\n<pre><strong>$ sh install.sh<\/strong><\/pre>\n<p>Once the installation is complete, a success message will be displayed on the terminal. To confirm CSF is installed and running correctly, execute the command below:<\/p>\n<pre><strong>$ sudo perl \/usr\/local\/csf\/bin\/csftest.pl<\/strong><\/pre>\n<p>The output will be as follows.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"752\" height=\"276\" class=\"wp-image-11303\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-377.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-377.png 752w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-377-300x110.png 300w\" sizes=\"auto, (max-width: 752px) 100vw, 752px\" \/><\/p>\n<h2><strong>Step 5: Configure Config Server Firewall<\/strong><\/h2>\n<p>CSF can be configured by editing its configuration file that is in the path <strong>\/etc\/csf\/csf.conf.<\/strong><\/p>\n<pre><strong>$ sudo nano \/etc\/csf\/csf.conf<\/strong><\/pre>\n<p>Change the following lines at the beginning of the config file:<\/p>\n<pre><strong>TESTING = \"0\"<\/strong><\/pre>\n<pre><strong>RESTRICT_SYSLOG = \"3\"<\/strong><\/pre>\n<p>Save and reload CSF using the commands below:<\/p>\n<pre><strong>$ sudo csf -ra<\/strong><\/pre>\n<p>You can also check the status of CSF with the following command:<\/p>\n<pre><strong>$ sudo systemctl status csf<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"1052\" height=\"329\" class=\"wp-image-11304\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-378.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-378.png 1052w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-378-300x94.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-378-1024x320.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-378-768x240.png 768w\" sizes=\"auto, (max-width: 1052px) 100vw, 1052px\" \/><\/strong><\/p>\n<p>From the output above, the CSF service is up and running.<\/p>\n<p>The CSF configuration file offers a wide range of settings. The default settings are generally satisfactory and can be used on practically any server. Common attacks such as port scans, flood attacks, and unauthorized access attempts are blocked by the default settings in the file.<\/p>\n<p>If you want to fine-tune your configuration even further read the comments in the \/etc\/csf\/csf.conf and make the necessary changes.<\/p>\n<h2><strong>Step 5: Manage CSF with Command Line<\/strong><\/h2>\n<p>You can manage the CSF firewall using the command line. You can allow, deny, or ban an IP address. Below are examples of how to use the csf command.<\/p>\n<p>Allow a specific IP address as shown:<\/p>\n<pre><strong>$ csf -a ip_address<\/strong><\/pre>\n<p>Deny an IP address using the -d option followed by the IP address as shown:<\/p>\n<pre><strong>$ csf -d ip_address<\/strong><\/pre>\n<p>To remove a blocked IP address from a CSF rule, run:<\/p>\n<pre><strong>$ csf -dr ip_address<\/strong><\/pre>\n<p>To display all firewall rules, run:<\/p>\n<pre><strong>$ csf -l<\/strong><\/pre>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>That\u2019s it with installing Config Server Firewall on Ubuntu 20.04.<\/p>","protected":false},"excerpt":{"rendered":"<p>Config Server Firewall (CSF) is a free and open-source firewall that is used to protect Linux servers from unauthenticated users. Services such as SSH, SMTP, HTTP, IMAP, POP3,&hellip;<\/p>","protected":false},"author":1,"featured_media":11681,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[197,100],"class_list":["post-11301","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","tag-firewall","tag-ubuntu-20-04"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/11301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=11301"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/11301\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/11681"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=11301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=11301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=11301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}