WordPress – OpenCart – SEO – Web Development

Hướng dẫn cài đặt CSF (Config Server Firewall) trên Direct Admin

CSF là một phần mềm tường lửa khá tốt giúp tăng cường bảo mật cho VPS giúp chống lại các cuộc tấn công brute-force, port-scans, block IP ...v..v.. Đặc biệt đối với người sử dụng control panel Direct Admin, dưới đây iNET hướng dẫn bạn thực hiện cài đặt và cấu hình cơ bản CSF cho VPS.

Nếu bạn chưa có máy chủ hoặc đang có nhu cầu tìm mua VPS chất lượng cao, bạn có thể truy nhập vào đây để lựa chọn cho mình 1 VPS được xây dựng trên cloud iNET.

Các bước thực hiện cài đặt csf trên direct admin.

Bước 1: SSH vào VPS

Bước 2: Các bước cài đặt

[root@vps ~]# cd /usr/local/src/

Tải phần mềm CSF về máy chủ:
[root@vps src]# wget https://download.configserver.com/csf.tgz

--2016-06-21 15:12:39--  http://configserver.com/free/csf.tgz
Resolving configserver.com... 109.70.137.78, 2a01:c0:2:22::3
Connecting to configserver.com|109.70.137.78|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://download.configserver.com/csf.tgz [following]
--2016-06-21 15:12:40--  http://download.configserver.com/csf.tgz
Resolving download.configserver.com... 85.10.199.177
Connecting to download.configserver.com|85.10.199.177|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 693991 (678K) [application/x-gzip]
Saving to: “csf.tgz”

100%[=========================================================>] 693,991      233K/s   in 2.9s


Giải nén chương trình:
[root@vps src]# tar -xzf csf.tgz

Vào thư mục csf vừa được giải nén:
[root@vps src]# cd csf

Chạy lệnh cài đặt chương trình:
[root@vps src]# sh install.directadmin.sh

Installing csf and lfd

Check we're running as root

Checking Perl modules...
Using configuration defaults
...Perl modules OK

mkdir: created directory `/etc/csf'
mkdir: created directory `/var/lib/csf'
mkdir: created directory `/var/lib/csf/backup'
mkdir: created directory `/var/lib/csf/Geo'
mkdir: created directory `/var/lib/csf/ui'
mkdir: created directory `/var/lib/csf/stats'
mkdir: created directory `/var/lib/csf/lock'
mkdir: created directory `/var/lib/csf/webmin'
mkdir: created directory `/var/lib/csf/zone'
mkdir: created directory `/usr/local/csf'
mkdir: created directory `/usr/local/csf/bin'
mkdir: created directory `/usr/local/csf/lib'
mkdir: created directory `/usr/local/csf/tpl'
`csf.directadmin.conf' -> `/etc/csf/csf.conf'
`csf.allow' -> `/etc/csf/./csf.allow'
`csf.deny' -> `/etc/csf/./csf.deny'
`csf.redirect' -> `/etc/csf/./csf.redirect'
.......

mode of `/usr/local/directadmin/plugins/csf/scripts/update.sh' changed to 0755 (rwxr-xr-x)
changed ownership of `/usr/local/directadmin/plugins/csf/exec/csf' to root:root
mode of `/usr/local/directadmin/plugins/csf/exec/csf' changed to 4755 (rwsr-xr-x)
`lfd.sh' -> `/etc/init.d/lfd'
`csf.sh' -> `/etc/init.d/csf'
mode of `/etc/init.d/lfd' retained as 0755 (rwxr-xr-x)
mode of `/etc/init.d/csf' retained as 0755 (rwxr-xr-x)
`/etc/csf/csfwebmin.tgz' -> `/usr/local/csf/csfwebmin.tgz'

Installation Completed

Quá trình cài đặt thành công, bạn có thể check lại kết quả bằng lệnh sau.

[root@vps ~]# 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...OK
Testing iptable_nat/ipt_DNAT...OK

RESULT: csf should function on this server
 

Đăng nhập Direct Admin và kiểm tra:

Trạng thái CSF đang ở chế độ Off, chọn Enable để bật CSF lên

Nếu nhận được thông báo lỗi:

*WARNING* URLGET set to use LWP but perl module is not installed, reverting to HTTP::Tiny

Bạn cần cài đặt thêm gói perl:

[root@server csf]# yum install perl-libwww-perl

Sau khi cài đặt thành công, dùng lệnh sau để khởi động lại CSF

[root@server csf]# csf -e

Kiểm tra lại trên trình duyệt vẫn còn thông báo như bên dưới:

Chỉnh lại cấu hình:

Chuyển chế độ TESTING từ ON thành OFF

Lưu lại cấu hình và kiểm tra lại kết quả:

Như vậy là cấu hình thành công CSF thành công trên Direct Admin, ngoài cấu hình cơ bản trên bạn có thể tùy ý cấu hình chi tiết hơn nhằm tăng cường bảo mật cho VPS.

Chúc bạn thực hiện thành công !

Giới thiệu tác giả

Giới thiệu tác giả: .

Gửi bình luận

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Top