
我嘗試建立iptables
規則來防止我的伺服器連線限制被客戶端未傳回 ACK 封包的未完成的 SYN 封包填滿(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
伺服器是運行Centos 7.6的Digital Ocean VPS,核心:3.10.0-862.2.3.el7.x86_64
任何人都可以幫助解釋為什麼 SYNPROXY 可能無法運行,或者為什麼/如何保護我的伺服器免受 SYN 泛洪攻擊?