上周给朋友帮忙, 上架了一款小游戏 (年年有鱼), 项目刚一上线, 就遇到了 ddos 攻击, 阿里云连续给出了 6 次 ddos 预警提示, 服务器一度处于黑洞状态, 很是无奈...
基于此, 我学习了一下 CentOS 服务器监控访问 ip, 并通过防火墙禁用 ip
使用 iftop 查看访问 ip
我们在 shell 直接输入 iftop, 有可能会提示我们无此命令, 这时我们需要安装 iftop
yum install iftop -y
如图:
效果
iptables 禁用非法 ip
iptables -I INPUT -s ip -j DROP
这个命令是在 iptables 防火墙配置文件中, 加入了你想要禁用的 ip, 接下来还要保存 iptables 这个文件
service iptables restart
之后重启防火墙
service iptables restart
使用 which 查看 iptables 在服务器什么地方
which iptables
查看 iptables 文件里都用那些内容
cat /usr/sbin/iptables
来源: http://www.bubuko.com/infodetail-2927264.html