CSF: Config Server Firewall Installation
An alternative firewall to APF is that the Config Server Firewall, or CSF:
CSF is mostly thought-about a additional advanced firewall as there are additional configuration choices compared to alternative firewalls, whereas still being easy enough to put in and tack that even novice directors will use it. this text can provide you with a straightforward summary regarding a way to install and setup CSF and its security plugin LFD (Login Failure Daemon).
This post assumes that you just are aware of SSH and basic instruction navigation. These directions apply primarily to customers UN agency have VPS or Dedicated servers. If you are doing not have root-level access to your server account you’ll not be able to create these changes.
Removing Your Current Firewall:
To prevent any conflicts operational we are going to have to be compelled to take away your current firewall. the foremost common software system firewalls on our dedicated servers square measure APF and CSF, therefore we’ve got provided directions on a way to take away APF below. If you’re employing a totally different software system firewall make certain to follow that programs uninstall directions before continued. when finishing the uninstall continue with the CSF installation below.
Using Yum to Remove APF:
If it was installed via yum, which is most likely, you will first need to identify the name of your APF package:
In this case:
In order to remove that package, and get your server ready for CSF installation, run the following command:
If you see this:
It means you have BFD installed, and it will need to be removed before you can proceed to removing APF:
Then attempt to remove apf again:
Removing Source Installed APF:
This can be a small amount trickier, and if you’re undecided what you’re doing you will wish to submit a price ticket to our support team. If you’re assured and need to proceed you may realize a listing of commands below that you just will use to get rid of APF if it’s put in within the commonest CentOS directories.
Stopping APF and iptables clears all of the foundations from your firewall and ensures that removing the APF installation won’t cause access problems:
Remove all of the APF related files:
Remove APF from the list of programs that start at boot:
If you get error on any of these commands that you simply don’t perceive please open a price ticket with our support team and that we can do everything we will to help you.
Installing CSF ought to be as straightforward as downloading the supply file to your server and putting in it. All commands below ought to be dead on your server via SSH, not on your native PC.
The first few steps of the installation square measure identical whether or not it’s a cPanel server or a non-cPanel server.
Retrieving the Package:
Best apply once putting in any software package from source: Use a brief directory on a partition with lots of house.
On our dedicated cPanel servers you’ll have already got a directory that we have a tendency to typically use for such things known as ‘temp’ on the house partition:
It is a good idea to check your disk space usage before proceeding, just to be sure there is plenty available:
Use ‘wget’ to retrieve CSF install code:
Once the download is complete, you will see something similar to the following, and be given a command prompt again:
Next: Decompress the CSF install files and change directories to the newly created ‘csf’ directory:
This is where the paths diverge: cPanel server, or non-cPanel server.
If you are running a non-cpanel redhat server:
Either method you’ll be able to check the output of the script because it is running and it’ll tell you everything it’s done. At the end, you’ll see one thing just like the following:
TCP ports currently listening for incoming connections:
UDP ports currently listening for incoming connections:
Note: The port details above are for information only, csf hasn’t been auto-configured.
Don’t forget to:
- Configure the TCP_IN, TCP_OUT, UDP_IN and UDP_OUT options in the csf configuration to suite your server
- Restart csf and lfd
- Set TESTING to 0 once you’re happy with the firewall
Adding current SSH session IP address to the csf whitelist in csf.allow:
Adding 10.30.6.17 to csf.allow only while in TESTING
mode (not iptables ACCEPT)
*WARNING* TESTING mode is enabled
– do not forget to disable it in the configuration
To start testing CSF, start it up:
Once you’ve got completed your testing be sure to require CSF out of testing mode by changing the flag within the csf.conf:
Edit the configuration along with your favorite editor, during this case we are going to use vi:
Find this block of text near the top of the configuration file:
Edit the last line of that block of text so that it reflects testing being disabled:
Finally, restart CSF:
Your CSF firewall is up and running! Congratulations!
Common Installation Errors:
If you see an error about libwww not being installed you can install it with yum or cpan:
Beginning CSF: Making Changes Using the Command Line:
Updating CSF using the command line interface is simple by design!
Here are the most common commands you will be using:
- csf -d IPADDRESS will deny an IP.
- csf -a IPADDRESS will allow an IP.
- csf -r will reload all rules.
If you forget the command you are looking for just type ‘csf‘ on the command line and you will receive an list of all of your options:
[[email protected] ~ ]# csf ConfigServer Security & Firewall (http://www.configserver.com/cp/csf/) csf: v4.17 (c)2006, Way to the Web Limited (http://www.waytotheweb.com) Usage: /usr/sbin/csf [option] [value] Option Meaning -h, --help Show this message -l, --status List/Show iptables configuration -s, --start Start firewall rules -f, --stop Flush/Stop firewall rules -r, --restart Restart firewall rules -a, --add ip Add an IP address to be whitelisted to /etc/csf.allow -d, --deny ip Add an IP address to be blocked to /etc/csf.deny -dr, --denyrm ip Remove and unblock an IP address in /etc/csf.deny -c, --check Checks for updates to csf+lfd but does not perform an upgrade -g, --grep ip Search the iptables rules for an IP match (incl. CIDR) -t, --temp Displays the current list of temporary IP bans and their TTL -tr, --temprm ip Remove an IP address from the temporary IP ban list -td, --tempdeny ip ttl [-p port] [-d direction] Add an IP address to the temporary IP ban list. ttl is how long to blocks for in seconds. Optional port. Optional direction of block can be one of in, out or inout. Default is in -tf, --tempf Flush all IP addresses from the temporary IP ban list -u, --update Checks for updates to csf+lfd and performs an upgrade if available -x, --disable Disable csf and lfd -e, --enable Enable csf and lfd if previously disabled -v, --version Show csf version
CSF is an progressively widespread various to the stock firewalls on some servers. do you have to need the other facilitate or have any questions on CSF please open a price ticket with our support team by work in to your manage account, otherwise you also can visit the CSF home page wherever you’ll notice different documentation and FAQs.