大网数据广告活动
服务器运维问答

insert multiple iptables rules in critical situations

· 52CE 我爱测

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 imp…

问题原文

原帖链接 · 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

  1. 1500 of similar rules is a very bad idea, because the performance will significantly degraded. Better look at the ipset match (it uses hash tables, so this is very fast).
  2. Don't use the ufw.
  3. Run the iptables-save > current-ruleset.ipv4.
  4. Edit this file and save it under new name (anti-ddos-ruleset.ipv4)
  5. Check the corectness of your rules with the iptables-restore -t anti-ddos-ruleset.ipv4 command. Fix errors if present.
  6. Now you can atomically load the rules with the iptables-restore anti-ddos-ruleset.ipv4.
  7. You can apply the new rules with confirmation with the iptables-apply -t 60 anti-ddos-ruleset.ipv4 command. If you don't confirm the new rule set it will be rolled back to previous version.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-08-22)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。