UnixServerAdmin

Server Administration & Management

How to make Virtuozzo Container be able to run ConfigServer Firewall(CSF)

CSF is a powerful Firewall for Linux and cPanel servers are here are the steps to get it working with Virtuozzo VPS

1. Installation

# rm -rvf csf.tgz
# wget http://www.configserver.com/free/csf.tgz
# tar -xzf csf.tgz
# cd csf
# sh install.sh

2. After the installation you will need to customize CSF to run on VPS, edit /etc/sysconfig/iptables and add

# vi /etc/sysconfig/iptables
——————————————–
-A FORWARD -j ACCEPT -p all -s 0/0 -i venet0
-A FORWARD -j ACCEPT -p all -s 0/0 -o venet0
-A INPUT -i venet0 -j ACCEPT
-A OUTPUT -o venet0 -j ACCEPT
——————————————–

3. Create file /etc/csf/csfpre.sh and enter all the extra rules directly into it prefixed with “iptables” so the contents of that file should look something like:

# vi /etc/csf/csfpre.sh
——————————————————
iptables -A INPUT -i venet0 -j ACCEPT
iptables -A OUTPUT -o venet0 -j ACCEPT
iptables -A FORWARD -j ACCEPT -p all -s 0/0 -i venet0
iptables -A FORWARD -j ACCEPT -p all -s 0/0 -o venet0
——————————————————

4. edit /etc/csf/csf.conf file and add and search for

# vi /etc/csf/csf.conf file
——————————
ETH_DEVICE = “”
change to
ETH_DEVICE = “venet+”
——————————

5. Restart

# /usr/sbin/csf -r  “OR”

# /etc/init.d/csf restart

==================================================================
Lockout Issues for CSF, when installed in VPS

“or”

Cannot enter into server after CSF installation on VPS

If the required IP table modules are not properly loaded to the container node, you may lockout yourself after the installation. If you have access to the main Hardware node, you can perform the following to get it up or ask your VPS provider to perform this on the Hardware (main) node.

Before enabling iptables on VPS, it needs to make sure that the iptables modules are enabled on the Hardware Node. In order to enable iptables modules on Hardware Node, Edit it as the following:-

# /etc/vz/vz.conf
——————————–
IPTABLES_MODULES=”ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ip_conntrack_ftp ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp xt_state ipt_recent”
——————————–

# /etc/sysconfig/iptables-config
——————————–
IPTABLES_MODULES=”ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ip_conntrack_ftp ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp xt_state ipt_recent”
——————————–

Now your Hardware node is fine. You need to enable the iptable modules to the VPS nodes. (CID – container ID. You can find the value for each node by using the command vzlist -a)

# vzctl stop CID

# vzctl set CID –iptables ipt_REJECT –iptables ipt_tos –iptables ipt_TOS –iptables ipt_LOG –iptables ip_conntrack –iptables ipt_limit –iptables ipt_multiport –iptables iptable_filter –iptables iptable_mangle –iptables ipt_TCPMSS –iptables ipt_tcpmss –iptables ipt_ttl –iptables ipt_length  –iptables ipt_state –iptables iptable_nat –iptables ip_nat_ftp –save

# vzctl set CID –numiptent 2000 –save

# vzctl start CID

Now try entering into your node and restart CSF. It should start working fine.

Advertisements

October 28, 2011 Posted by | CSF, Firewall, Virtualization, Virtuozzo | , , , , | Leave a comment