這篇文章主要介紹了iptables防火牆實現阻擋常見攻擊的實用設定分享,本文講解了防止 syn 洪水攻擊、丟棄 null 空資料報、丟棄異常的 xmas 資料報、丟棄無效資料報等應對異常資料的設定方法,需要的朋友可以參考下
初始建立的 tcp 連線必須含 syn
iptables -a input -p tcp ! --syn -m state --state new -j drop
丟棄 fragments 碎片資料報 (碎片資料報攻擊的後果: 可能導致正常資料報丟失)
iptables -a input -f -j drop
防止 syn 洪水攻擊 (限制的速度根據自身情況調整)
iptables -a input -p tcp -m state --state new -m limit --limit 100/second --limit-burst 300 -j accept
iptables -a input -p tcp -m state --state new -j drop
丟棄異常的 xmas 資料報 (異常的 xmas 資料報攻擊的後果: 可能導致某些系統崩潰)
iptables -a input -p tcp --tcp-flags all all -j drop
iptables -a input -p tcp --tcp-flags all fin,psh,urg -j drop
iptables -a input -p tcp --tcp-flags all syn,rst,ack,fin,urg -j drop
丟棄 null 空資料報
iptables -a inpit -p tcp --tcp-flags all none -j drop
允許有限的 tcp rst 請求 (限制的速度根據自身情況調整)
iptables -a input -p tcp -m tcp --tcp-flags rst rst -m limit --limit 10/second --limit-burst 30 -j accept
丟棄無效資料報
iptables -a input -m state --state invalid -j drop
iptables -a forward -m state --state invalid -j drop
iptables -a output -m state --state invalid -j drop
阻擋欺詐 ip 位址的訪問 (以下為 rfc1918 型別和 iana 預留位址,多為 lan 或者多播位址,這些是不可能作為公網位址源的)
**如下:
iptables -a input -s 10.0.0.0/8 -j drop
iptables -a input -s 169.254.0.0/16 -j drop
iptables -a input -s 172.16.0.0/12 -j drop
iptables -a input -s 127.0.0.0/8 -j drop
iptables -a input -s 224.0.0.0/4 -j drop
iptables -a input -d 224.0.0.0/4 -j drop
iptables -a input -s 240.0.0.0/5 -j drop
iptables -a input -d 240.0.0.0/5 -j drop
iptables -a input -s 0.0.0.0/8 -j drop
iptables -a input -d 0.0.0.0/8 -j drop
iptables -a input -d 239.255.255.0/24 -j drop
iptables -a input -d 255.255.255.255 -j drop
阻擋自定義的惡意 ip 位址的訪問
iptables -a input -s ***.***.***.*** -j drop
禁止 icmp ping
iptables -a input -p icmp -m icmp --icmp-type echo-request -j drop
Linux Iptables命令詳解
ipaddr ipaddr port port 可以指定乙個單一的新的ip位址,乙個ip位址範圍,也可以附加乙個埠範圍 只能在指定 p tcp 或者 p udp的規則裡 如果未指定埠範圍,源埠中512以下的 埠 會被安置為其他的512以下的埠 512到1024之間的埠會被安置為1024以下的,其他埠...
Linux iptables規則詳解
filter input drop 345 43237 forward accept 0 0 output accept 306 41346 ainput p tcp m tcp dport 10022 j accept ainput p tcp m tcp dport 80 j accept ai...
Linux iptables基本管理
1.iptables基本管理 問題本案例要求熟悉iptables工具的基本管理,分別練習以下幾方面的操作 檢視當前生效的防火牆規則列表 追加 插入新的防火牆規則,修改現有的防火牆規則 刪除 清空指定的防火牆規則 方案採用兩台rhel6虛擬機器,在其中svr5上配置iptables防火牆規則,pc20...