Wednesday, November 2, 2016

Install CSF (firewall) on any Linux




below are the steps to install the firewall named ConfigServer Security & Firewall which can be installed on any flavor of Linux. I have installed it on CentOS 7.

cd /usr/local/src

rm -fv csf.tgz

Download the package using
wget https://download.configserver.com/csf.tgz

extract it
tar -xzf csf.tgz

change directory
cd csf

install it
sh install.sh

To test if CSF will work in the server can be found by running,
perl /usr/local/csf/bin/csftest.pl

befor executing above command please check once is your system having perl installed or not
using command : perl -v

if not installed install it using below command
yum install perl

Now, open
vi /etc/csf/csf.conf

Edit the Testing Flag
TESTING = "0"

now run below command to start csf
csf -r
/etc/init.d/csf restart   or
systemctl restart csf


some basic command which can be useful

to block IP with CSF
csf -d (Ip Address)

to allow IP with CSF
csf -a (Ip Address)

unblock an IP with CSF
csf -dr (Ip Address)

unblock temporarily blocked IP
csf -tr (Ip Address)

csf -s – Start firewall rules

csf -f – Flush/stop firewall rules

csf -r – Restart firewall rules

csf -x – Disable CSF

csf -e – Enable CSF

csf -c – Check for updates

csf -h – Show help screen