The following is a guide to installing ConfigServer Services‘ firewall and login failure daemon.
Warning: The Latest version of CSF does not work properly with DirectAdmin on CentOS 5 machines with Apache 2+
CSF + LFD is a full security suite. I have provided a list of the features that I have personally tested and have made work on a DirectAdmin server. I will include this list at the bottom of this post.
CSF + LFD have most of the functions APF provides, and more security features and brute force detection tools than BFD provides. It provides protection for small-scale DDoS attacks and SYN flood protection. A script to uninstall APF and BFD is included.
To install:
First, check to make sure there are no existing copies of csf in the folder:
rm -fv csf.tgz
Then:
wget http://www.configserver.com/free/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh
CSF has now been installed at etc/csf
If you have APF and BFD installed you must remove them:
sh /etc/csf/remove_apf_bfd.sh
By default, the firewall is set to testing mode and many of the features are turned off. To turn your firewall on and modify the settings edit up your csf.conf file located in:
cd /etc/csf
I’ve created a generic csf.conf file that you may download from our server. This file will work on most DirectAdmin installations. I have only checked it on CentOS. Delete your current csf.conf file and:
cd etc/csf
wget http://oakdns.net/downloads/csf.conf
Be sure to chmod the conf file to 600 once you have downloaded it and change the following line:
TESTING = “1″
to
TESTING = “0″
Finally, turn the firewall on:
/usr/sbin/csf -s
——
At this point you are done. Your firewall is configured, your logins are being monitored, and you have basic DDoS protection. Read on if you are ready for more advanced configurations.
—–
In my generic the root user will receive email alerts, the Spamhaus filter is turned ON, connection monitoring will drop anyone that attempts to open 200 or more connections per second, and any user that uses the wrong password 20 times in a row is banned permanently.
I highly recommend you modify this file to suit your needs. I will provide a little guidance in this post, but it is your responsibility to learn what each feature does and decide whether to use it.
Key features that you may want to change:
Set the firewall to autoupdate. I recommend you do NOT do this, but the feature does exist:
AUTO_UPDATES = “1″
Raise the limit on the number of IP addresses you keep permanently banned. Replace 100 with the number of your choice. Remember, iptables will create 4 rules per IP address so this may slow down your server if you set it too high. If you set this value to 0 there will be no limit. I recommend you do NOT set the value to 0 as your list of blocked IP addresses will grow indefinitely and slow your server to a halt.
DENY_IP_LIMIT = “100″
Raise the limit on the number of IP addresses you keep temporarily banned. Replace 100 with your new limit. Again, it is highly recommended that you do not set it to 0.
DENY_TEMP_IP_LIMIT = “100″
Temporarily ban offenders rather than permanently banning them. This is a recommended change. Change 1 to a value in seconds. I recommend 3600, or an hour ban.
LF_TRIGGER_PERM = “3600″
Configure the system integrity monitor to check more or less often. I’ve set it to check once every hour in my generic file. Change the value in seconds. I would not make it less than 3600 seconds or you’ll create a high I/O load on the server.
LF_INTEGRITY = “3600″
Turn DShield, Spamhaus, or Bognos IP blocking on or off. I keep Spamhaus on as they run a tight ship and only block IP addresses that are known spammers beyond any doubt. I have no experience with DShield or Bogon. Set the value to 0 to disable, 1 to enable.
LF_DSHIELD = “0″
LF_SPAMHAUS = “1″
LF_BOGON = “0″
Change the connection tracking limit. Connection tracking checks how many connections a visitor is opening to your server. It’s effective in blocking small attacks. I’ve set my file to block any IP using more than 200 connections per second. You may make the value higher or lower, but if you set it too low it will block legitimate visitors, and if you set it too high it won’t catch small DOS attacks.
CT_LIMIT = “200″
Warn you if your server load goes over X. I’ve set it to 6 in my file.
PT_LOAD_LEVEL = “6″
Features that are known to work with DirectAdmin:
SPI iptables firewall
Daemon process that checks for login authentication failures for:
ssh
password protected web pages (htpasswd)
mod_security failures
suhosin failures
SSH login notification
SU login notification
Some DDoS protection:
Excessive connection blocking
A built in integrity checker:
Suspicious process reporting – reports potential exploits running on the server
Excessive user processes reporting
Excessive user process usage reporting and optional termination
Suspicious file reporting – reports potential exploit files in /tmp and similar directories
Alert sent if server load average remains high for a specified length of time
Directory and file watching – reports if a watched directory or a file changes
Block traffic on the DShield Block List and the Spamhaus DROP List
BOGON packet protection
IDS (Intrusion Detection System) – the last line of detection alerts you to changes to system and application binaries
SYN Flood protection
Ping of death protection
Port Scan tracking and blocking
Permanent and Temporary (with TTL) IP blocking
Exploit checks
Account modification tracking
Copy http://directadmin.com/forum/showthread.php?t=27315