Hướng dẫn cài đặt CSF trên Parallels Cloud Server (Virtuozzo Containers…)
1. Enable các module iptables hỗ trợ CSF trên Server Node
- Thêm dòng sau vào file /etc/sysconfig/iptables-config
#vi /etc/sysconfig/iptables-config
Trích dẫn:
|
IPTABLES_MODULES="ip_conntrack_netbios_ns ipt_conntrack ipt_LOG ipt_owner ipt_state ip_conntrack_ftp iptable_nat ip_nat_ftp ip_tables ipt_multiport iptable_filter ipt_limit ipt_recent xt_connlimit ipt_REDIRECT"
|
- Khởi động lại iptables
#service iptables restart
- Thêm dòng sau vào /etc/vz/vz.conf
#vi /etc/vz/vz.conf
Trích dẫn:
|
IPTABLES="ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp ip_tables ipt_conntrack ip_conntrack_ftp ipt_LOG ipt_owner ipt_REDIRECT ipt_recent xt_connlimit"
|
- Restart lại dịch vụ vz (tất cả container và dịch vụ vz sẽ được restart lại)
# /etc/init.d/vz restart
2. Cài đặt CSF vào Containers
- SSH vào Container và thực hiện các lệnh sau để cài đặt CSF
#rm -fv csf.tgz
#wget http://www.configserver.com/free/csf.tgz
#tar -xzf csf.tgz
#cd csf
Test xem trên server đã load đủ các module
# perl /usr/local/csf/bin/csftest.pl
Testing ip_tables/iptable_filter...OK
Testing ipt_LOG...OK
Testing ipt_multiport/xt_multiport...OK
Testing ipt_REJECT...OK
Testing ipt_state/xt_state...OK
Testing ipt_limit/xt_limit...OK
Testing ipt_recent...OK
Testing xt_connlimit...OK
Testing ipt_owner/xt_owner...OK
Testing iptable_nat/ipt_REDIRECT...FAILED [Error: iptables v1.4.7: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)] - Required for MESSENGER feature
Testing iptable_nat/ipt_DNAT...FAILED [Error: iptables v1.4.7: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)] - Required for csf.redirect feature
or
# iptables -t nat -L
iptables v1.3.5: can't initialize iptables table `nat': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded.
Nếu bị lỗi như trên thì làm theo bài này để Fix
http://kb.parallels.com/en/113000
Cài đặt CSF bằng lệnh sau
#sh install.sh
- Tùy chỉnh CSF, thêm 4 dòng sau vào /etc/sysconfig/iptables
#vi /etc/sysconfig/iptables
Mã:
|
-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 |
Tạo file /etc/csf/csfpre.sh và thêm vào các rules ban đầu
#vi /etc/csf/csfpre.sh
Mã:
|
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 |
- Chỉnh sữa lại card mạng trong CSF
#vi /etc/csf/csf.conf
Tìm và thay thế dòng sau
ETH_DEVICE = ""
Thay thế bằng dòng
ETH_DEVICE = "venet0"
Chú ý: venet0 là card mạng trong containers-
Restart lại dịch vụ CSF bằng lệnh sau
#/usr/sbin/csf -r
3. How to Add Custom iptables Rules with CSF (Tham khảo thêm link bên dưới)
http://tecadmin.net/add-custom-iptables-rules-with-csf/
Chúc thành công!
VinaCIS System