SYNPROXY 似乎没有运行

SYNPROXY 似乎没有运行

我尝试创建iptables规则来防止我的服务器连接限制被未完成的 SYN 数据包填满,因为客户端没有返回任何 ACK 数据包(SYN 洪水攻击)。

我已经阅读了 [RFC 4987 TCP SYN 洪水攻击和常见缓解措施][1] 和 [使用 Red Hat Enterprise Linux 7 Beta 缓解 TCP SYN 洪水攻击][2],最后尝试按照 [此处][3] 的说明进行操作:https://javapipe.com/blog/iptables-ddos-protection/

但是,我的网站仍然很容易受到以下命令的 DOS 攻击而关闭:

hping -S --flood -V -p 443 www.mydomain.com

在上面链接的 Javapipe.com 教程的最后,提到了判断 SYNPROXY 是否处于活动状态的命令。

要验证 SYNPROXY 是否正常工作,您可以执行 watch -n1 cat /proc/net/stat/synproxy。如果在您使用 SYNPROXY 的端口上建立新的 TCP 连接时值发生变化,则表示它正常工作。

命令是:

watch -n1 cat /proc/net/stat/synproxy

当我在服务器上使用该命令并尝试加载页面时,数据不会改变且全为零。

Every 1.0s: cat /proc/net/stat/synproxy                                                                                                      Thu Jul 25 19:57:00 2019

entries         syn_received    cookie_invalid  cookie_valid    cookie_retrans  conn_reopened
00000000        00000000        00000000        00000000        00000000        00000000

以下是 iptables -L 的输出

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere            
INPUT_direct  all  --  anywhere             anywhere            
INPUT_ZONES_SOURCE  all  --  anywhere             anywhere            
INPUT_ZONES  all  --  anywhere             anywhere            
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited
REJECT     tcp  --  anywhere             anywhere             #conn src/32 > 80 reject-with tcp-reset
ACCEPT     tcp  --  anywhere             anywhere             ctstate NEW limit: avg 20/sec burst 20
DROP       tcp  --  anywhere             anywhere             ctstate NEW
ACCEPT     tcp  --  anywhere             anywhere             tcp flags:RST/RST limit: avg 2/sec burst 2
DROP       tcp  --  anywhere             anywhere             tcp flags:RST/RST
DROP       all  --  anywhere             anywhere             ctstate INVALID
SYNPROXY   tcp  --  anywhere             anywhere             tcp ctstate INVALID,UNTRACKED SYNPROXY sack-perm timestamp wscale 7 mss 1460 
DROP       all  --  anywhere             anywhere             ctstate INVALID
DROP       all  --  anywhere             anywhere             state INVALID

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere            
FORWARD_direct  all  --  anywhere             anywhere            
FORWARD_IN_ZONES_SOURCE  all  --  anywhere             anywhere            
FORWARD_IN_ZONES  all  --  anywhere             anywhere            
FORWARD_OUT_ZONES_SOURCE  all  --  anywhere             anywhere            
FORWARD_OUT_ZONES  all  --  anywhere             anywhere            
DROP       all  --  anywhere             anywhere             ctstate INVALID
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
OUTPUT_direct  all  --  anywhere             anywhere            

Chain FORWARD_IN_ZONES (1 references)
target     prot opt source               destination         
FWDI_public  all  --  anywhere             anywhere            [goto] 

Chain FORWARD_IN_ZONES_SOURCE (1 references)
target     prot opt source               destination         

Chain FORWARD_OUT_ZONES (1 references)
target     prot opt source               destination         
FWDO_public  all  --  anywhere             anywhere            [goto] 

Chain FORWARD_OUT_ZONES_SOURCE (1 references)
target     prot opt source               destination         

Chain FORWARD_direct (1 references)
target     prot opt source               destination         

Chain FWDI_public (1 references)
target     prot opt source               destination         
FWDI_public_log  all  --  anywhere             anywhere            
FWDI_public_deny  all  --  anywhere             anywhere            
FWDI_public_allow  all  --  anywhere             anywhere            
REJECT     icmp --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain FWDI_public_allow (1 references)
target     prot opt source               destination         

Chain FWDI_public_deny (1 references)
target     prot opt source               destination         

Chain FWDI_public_log (1 references)
target     prot opt source               destination         

Chain FWDO_public (1 references)
target     prot opt source               destination         
FWDO_public_log  all  --  anywhere             anywhere            
FWDO_public_deny  all  --  anywhere             anywhere            
FWDO_public_allow  all  --  anywhere             anywhere            

Chain FWDO_public_allow (1 references)
target     prot opt source               destination         

Chain FWDO_public_deny (1 references)
target     prot opt source               destination         

Chain FWDO_public_log (1 references)
target     prot opt source               destination         

Chain INPUT_ZONES (1 references)
target     prot opt source               destination         
IN_public  all  --  anywhere             anywhere            [goto] 

Chain INPUT_ZONES_SOURCE (1 references)
target     prot opt source               destination         

Chain INPUT_direct (1 references)
target     prot opt source               destination         

Chain IN_public (1 references)
target     prot opt source               destination         
IN_public_log  all  --  anywhere             anywhere            
IN_public_deny  all  --  anywhere             anywhere            
IN_public_allow  all  --  anywhere             anywhere            
REJECT     icmp --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain IN_public_allow (1 references)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh ctstate NEW
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http ctstate NEW
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https ctstate NEW
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:smtp ctstate NEW

Chain IN_public_deny (1 references)
target     prot opt source               destination         

Chain IN_public_log (1 references)
target     prot opt source               destination         

Chain OUTPUT_direct (1 references)
target     prot opt source               destination  

该服务器是使用 Digital Ocean 的 VPS,运行 Centos 7.6,内核:3.10.0-862.2.3.el7.x86_64

有人能帮忙解释一下为什么 SYNPROXY 可能没有运行,或者为什么/如何保护我的服务器免受 SYN 洪泛攻击吗?

相关内容