小编use*_*047的帖子

禁止IP的Shell脚本

一些 IP 正在打开我服务器的数千个连接。我有一台 Ubuntu 14 服务器。我使用以下命令检查总连接数:

netstat -an | grep tcp | awk '{print $5}' | 切 -f 1 -d : | 排序 | uniq -c | 排序 -n

然后我使用以下 iptables 规则来阻止罪魁祸首 IP。

iptables -I 输入 1 -s xxxx -j DROP

它工作正常并阻止IP地址。但是,我无法 24/7 全天候在线监控服务器。我想知道是否有任何可以用来自动执行此操作的 Shell 脚本?例如,如果一个 IP 在任何时候打开超过 X 个连接,它应该被上述 iptables 规则自动禁止。

iptables command-line scripts connection

8
推荐指数
1
解决办法
3887
查看次数

标签 统计

command-line ×1

connection ×1

iptables ×1

scripts ×1