![iptables TCP ルール](https://rvso.com/image/770089/iptables%20TCP%20%E3%83%AB%E3%83%BC%E3%83%AB.png)
iptables -t raw -F
iptables -t raw -I PREROUTING -j DROP -p tcp -m string --string "Mozil" --algo kmp --to 65535 -m tcp --dport 1000 # You can change the port here
iptables -t raw -I PREROUTING -j DROP -p tcp -m string --string "Saf" --algo kmp --to 65535 -m tcp --dport 1000
iptables -t raw -I PREROUTING -j DROP -p tcp -m string --string "Edge" --algo kmp --to 65535 -m tcp --dport 1000
iptables -t raw -I PREROUTING -j DROP -p tcp -m string --string "Oper" --algo kmp --to 65535 -m tcp --dport 1000
iptables -t raw -I PREROUTING -j DROP -p tcp -m string --string "Chrom" --algo kmp --to 65535 -m tcp --dport 1000
iptables -t raw -I PREROUTING -j DROP -p tcp -m string --string "Gecko" --algo kmp --to 65535 -m tcp --dport 1000
iptables -t raw -I PREROUTING -j DROP -p tcp -m string --string "Andr" --algo kmp --to 65535 -m tcp --dport 1000
iptables -t raw -I PREROUTING -j DROP -p tcp -m string --string "exch" --algo kmp --to 65535 -m tcp --dport 1000
iptables -t raw -I PREROUTING -j DROP -p tcp -m string --string "Fire" --algo kmp --to 65535 -m tcp --dport 1000
iptables -t raw -I PREROUTING -j DROP -p tcp -m string --string "Wind" --algo kmp --to 65535 -m tcp --dport 1000
アクセスしようとするとhttp://127.0.0.1:1000/接続を拒否されますが、試してみるとhttps://127.0.0.1:1000アクセスできました。なぜでしょうか? ところでありがとう!
これは、レイヤー 7 で DDoS 攻撃を受けているアプリケーション サーバーです。アプリケーションのソースがないため、iptables でブロックする解決策はありませんか? 同じルールでポート 443 をブロックするとどうなるでしょうか?
答え1
HTTP はプレーンテキストですが、HTTPS は暗号化されているためです。
それはさておき、特定のユーザー エージェントをブロックするためにこの方法を使用しないことを強くお勧めします。これは Web サーバー自体内で実行する必要があります。