iptables不会阻止一些IP地址

CentOS 6.2 – vsftpd正在运行

95.76.44.67后面的人每天扫描我的FTP服务器,我阻止他从iptables,但检查vsftpd.log我看到他仍然可以连接到vsftpd,我不知道为什么。

这是我的iptables输出:

Chain INPUT (policy ACCEPT 223K packets, 34M bytes) num pkts bytes target prot opt in out source destination 1 18709 1370K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:512 2 43135 2175K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:21 3 143K 181M ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpts:62222:63333 4 68342 94M ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:25 5 1 44 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:53 6 254K 30M ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306 7 8 472 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:465 8 103K 140M ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:587 9 122K 7662K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:995 10 7486 1039K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443 11 1201 114K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080 12 277K 595M ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 13 0 0 DROP all -- * * 70.148.48.200 0.0.0.0/0 14 2015 81956 DROP all -- * * 95.76.44.67 0.0.0.0/0 15 0 0 DROP all -- * * 95.76.133.243 0.0.0.0/0 16 0 0 DROP all -- * * 95.76.186.81 0.0.0.0/0 17 0 0 DROP all -- * * 95.76.102.135 0.0.0.0/0 18 0 0 DROP all -- * * 118.69.198.201 0.0.0.0/0 19 0 0 DROP all -- * * 69.94.28.73 0.0.0.0/0 20 0 0 DROP all -- * * 218.60.44.132 0.0.0.0/0 21 0 0 DROP all -- * * 80.232.232.9 0.0.0.0/0 22 0 0 DROP all -- * * 61.184.196.122 0.0.0.0/0 23 0 0 DROP all -- * * 61.51.18.235 0.0.0.0/0 24 0 0 DROP all -- * * 218.29.115.152 0.0.0.0/0 Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 1287K packets, 1178M bytes) num pkts bytes target prot opt in out source destination 

我可以做什么阻止他连接到vsftpd?

Iptables的第一条规则是匹配胜利,所以

 2 43135 2175K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:21 

允许港口21的连接赢得了

 14 2015 81956 DROP all -- * * 95.76.44.67 0.0.0.0/0 

因为,对于FTP连接,它从来没有动作。

在接受FTP之前,将DROP设置为95.76.44.67。 你可能想要改变实现这个命令为-I ...而不是-A ...

DROP规则需要在接受端口21上的FTP连接的规则之前。

iptables在第一个命中机制上工作。

对于一个完美的IPTABLE策略,首先删除所有内容并打开必要的端口。 在你的情况下把DROP规则放在ACCEPT之前。 它应该工作。

美好的一天。

稍微切题,但考虑像Shorewall( http://shorewall.net/ )的iptables前端。 您可以更直观的方式添加规则,只需运行“shorewall drop 1.2.3.4”即可dynamic删除给定的地址。

另外考虑fail2ban( http://www.fail2ban.org/ ),它可以扫描您的日志并自动删除某些IP地址。 它适用于原始的iptables或Shorewall。