
1. Sử dụng iptables để chống lại DOS
1
2
3
4
5
6
7
|
-A : Append
-p : Protocol
--dport : For ports
-m limit : To limit iptables extension
--limit 25/minute : Defines maximum of 25 connection per minute.
--limit-burst 100 : The limit/minute will be enforced only after the total number of connection have reached the limit-burst level, ie 100 here.
-j : Target
|
1
|
iptables -A INPUT -p tcp --dport 80 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
|
ví dụ:
1
2
3
4
5
|
root@test [~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
acctboth all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 limit: avg 25/min burst 100
|
2. Bảo vệ Server/VPS bằng CSF
Ta edit file csf.conf trong etc/csf.conf . ta có thể dùng trình soạn thảo vi hoặc dùng winscp hay filezilla vào trực tiếp chỉnh sửa csf.conf
1
|
vi /etc/csf/csf.conf
|
# To disable this feature, set this to 0
1
|
CT_LIMIT = "50"
|
1
2
|
# Leave this option empty to count all ports against CT_LIMIT
CT_PORTS = "80,53,22"
|
1
|
csf -r
|
3. Tham khảo một số giá trị CT trong CSF mà ta có thể chỉnh sửa:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# Connection Tracking interval. Set this to the the number of seconds between
# connection tracking scans
CT_INTERVAL = "30"
# Send an email alert if an IP address is blocked due to connection tracking
CT_EMAIL_ALERT = "1"
# If you want to make IP blocks permanent then set this to 1, otherwise blocks
# will be temporary and will be cleared after CT_BLOCK_TIME seconds
CT_PERMANENT = "0"
# If you opt for temporary IP blocks for CT, then the following is the interval
# in seconds that the IP will remained blocked for (e.g. 1800 = 30 mins)
CT_BLOCK_TIME = "1800"
# If you don't want to count the TIME_WAIT state against the connection count
# then set the following to "1"
CT_SKIP_TIME_WAIT = "0"
# If you only want to count specific states (e.g. SYN_RECV) then add the states
# to the following as a comma separated list. E.g. "SYN_RECV,TIME_WAIT"
#
# Leave this option empty to count all states against CT_LIMIT
CT_STATES = ""
|
source: http://www.hostingaz.info/1635-bao-ve-vpsserver-chong-lai-ddos-bang-iptables-hoac-csf.html
Không có nhận xét nào:
Đăng nhận xét