问题原文
原帖链接 · mahyard · CC BY-SA 4.0
I have about 1,500 iptables rules I need to apply just when the server is under attack. It should be easy to remove/add later based on the situation I have. any suggestion for me? for example it would be acceptable if I could import those rules in 1 line and later comment/uncomment that line. take it easy. I'm actually a programmer :)
已采纳解答
原帖链接 · Anton Danilov · CC BY-SA 4.0
- 1500 of similar rules is a very bad idea, because the performance will significantly degraded. Better look at the
ipsetmatch (it uses hash tables, so this is very fast). - Don't use the
ufw. - Run the
iptables-save > current-ruleset.ipv4. - Edit this file and save it under new name (
anti-ddos-ruleset.ipv4) - Check the corectness of your rules with the
iptables-restore -t anti-ddos-ruleset.ipv4command. Fix errors if present. - Now you can atomically load the rules with the
iptables-restore anti-ddos-ruleset.ipv4. - You can apply the new rules with confirmation with the
iptables-apply -t 60 anti-ddos-ruleset.ipv4command. If you don't confirm the new rule set it will be rolled back to previous version.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
