免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3531 | 回复: 7
打印 上一主题 下一主题

关于fail2ban里面的iptables防范DDOS失败问题请教 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-08-12 07:14 |只看该作者 |倒序浏览
一web服务器,access日志里面有大量的:

117.63.28.113 - - [12/Aug/2008:13:00:39 +0800] "GET / HTTP/1.1" 200 38652
58.218.35.224 - - [12/Aug/2008:13:00:40 +0800] "GET / HTTP/1.1" 200 38652
124.118.23.180 - - [12/Aug/2008:13:00:39 +0800] "GET / HTTP/1.1" 200 38652
124.118.23.180 - - [12/Aug/2008:13:00:39 +0800] "GET / HTTP/1.1" 200 38652
58.218.35.224 - - [12/Aug/2008:13:00:41 +0800] "GET / HTTP/1.1" 200 38652
58.218.35.224 - - [12/Aug/2008:13:00:35 +0800] "GET / HTTP/1.1" 200 38652


有人说是DDOS,推荐安装了fail2ban,可是启动似乎一直出错,系统centos 4.6

fail2ban的log:
2008-08-12 07:08:30,217 WARNING: #27818 attempt to initialize the firewalls
2008-08-12 07:08:31,308 ERROR: 'iptables -N fail2ban-Apache
iptables -A fail2ban-Apache -j RETURN
iptables -I INPUT -p all --dport http -j fail2ban-Apache' returned 512
2008-08-12 07:08:31,309 WARNING: Execution of command 'iptables -N fail2ban-Apache
iptables -A fail2ban-Apache -j RETURN
iptables -I INPUT -p all --dport http -j fail2ban-Apache' failed
2008-08-12 07:08:31,309 WARNING: #27819 attempt to initialize the firewalls


手工执行也出错:
[root@mail logrotate.d]# iptables -N fail2ban-Apache
iptables: Chain already exists
[root@mail logrotate.d]# iptables -A fail2ban-Apache -j RETURN
[root@mail logrotate.d]# iptables -I INPUT -p all --dport http -j fail2ban-Apache
iptables v1.2.11: Unknown arg `--dport'
Try `iptables -h' or 'iptables --help' for more information.
[root@mail logrotate.d]# iptables -I INPUT -p all --dports http -j fail2ban-Apache
iptables v1.2.11: Unknown arg `--dports'
Try `iptables -h' or 'iptables --help' for more information.


iptalbes -L 显示的这个chain,很多很长……
Chain fail2ban-Apache (0 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere
RETURN     all  --  anywhere             anywhere
RETURN     all  --  anywhere             anywhere
RETURN     all  --  anywhere             anywhere
…………


请问问题可能出在哪里?谢谢!

[ 本帖最后由 arbor 于 2008-8-12 13:30 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-08-12 12:50 |只看该作者
在网关的路由器里面禁止该IP,失败

2621#sh access-lists
Standard IP access list 1
    permit 192.168.10.0, wildcard bits 0.0.0.255
    permit 192.168.1.0, wildcard bits 0.0.0.255
    permit 192.168.30.0, wildcard bits 0.0.0.255
    permit 192.168.40.0, wildcard bits 0.0.0.255
    permit 192.168.50.0, wildcard bits 0.0.0.255
    permit 192.168.60.0, wildcard bits 0.0.0.255
    permit 192.168.70.0, wildcard bits 0.0.0.255
    permit 192.168.80.0, wildcard bits 0.0.0.255
    permit 192.168.90.0, wildcard bits 0.0.0.255
    permit 192.168.20.0, wildcard bits 0.0.0.255
Extended IP access list 102
    permit icmp any any unreachable
    permit icmp any any administratively-prohibited
    permit icmp any any packet-too-big
    permit icmp any any time-exceeded
    permit icmp any any echo-reply
Extended IP access list 103
    deny ip host 221.133.204.4 any
    deny ip host 117.63.28.113 any
    deny ip host 124.118.23.180 any
    deny ip host 58.218.35.224 any

2621#


在服务器里面用iptables直接drop该ip,失败

iptables -A INPUT -s 117.63.28.113 -j DROP
[root@mail httpd]# iptables -A INPUT -s 124.118.23.180 -j DROP
[root@mail httpd]# iptables -A INPUT -s 58.218.35.224 -j DROP


再查看web日志,access里面仍然有大量的:

117.63.28.113 - - [12/Aug/2008:13:00:39 +0800] "GET / HTTP/1.1" 200 38652
58.218.35.224 - - [12/Aug/2008:13:00:40 +0800] "GET / HTTP/1.1" 200 38652
124.118.23.180 - - [12/Aug/2008:13:00:39 +0800] "GET / HTTP/1.1" 200 38652
124.118.23.180 - - [12/Aug/2008:13:00:39 +0800] "GET / HTTP/1.1" 200 38652
58.218.35.224 - - [12/Aug/2008:13:00:41 +0800] "GET / HTTP/1.1" 200 38652
58.218.35.224 - - [12/Aug/2008:13:00:35 +0800] "GET / HTTP/1.1" 200 38652


为什么防不住啊?

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
3 [报告]
发表于 2008-08-12 22:52 |只看该作者
fail2ban这个工具我之前不了解,但是看你的执行好象是一个脚本,具体就是执行iptables命令。
看你的命令应该是加了iptable的一条自定义链。
看你给出的命令,还有明显的报错信息:

[root@mail logrotate.d]# iptables -I INPUT -p all --dport http -j fail2ban-Apache
iptables v1.2.11: Unknown arg `--dport'
Try `iptables -h' or 'iptables --help' for more information.
[root@mail logrotate.d]# iptables -I INPUT -p all --dports http -j fail2ban-Apache
iptables v1.2.11: Unknown arg `--dports'
Try `iptables -h' or 'iptables --help' for more information.

这里的提示应该是参数使用错误吧。先替换http为数字端口试一下。在检查一下--dport使用的位置。

这个问题解决之后,咱们再看其他问题吧。

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
4 [报告]
发表于 2008-08-12 23:19 |只看该作者
iptables -I INPUT -p all --dport http -j fail2ban-Apache
这条命令中有以下问题:
1. --dport是TCP或者UDP的匹配扩展中才使用的参数选项,所以-p选项应该为-p tcp 或 -p udp
2. -p all 这个all参数是否可以使用,LZ自己确定一下。因为-p后面跟的是某种协议的扩展match,而对于TCP,UDP,ICMP,它们各自的扩展参数都是不一样的,我觉得-p all是不能使用的,但没有具体查证。

论坛徽章:
0
5 [报告]
发表于 2008-08-13 10:10 |只看该作者
原帖由 Godbach 于 2008-8-12 23:19 发表
iptables -I INPUT -p all --dport http -j fail2ban-Apache
这条命令中有以下问题:
1. --dport是TCP或者UDP的匹配扩展中才使用的参数选项,所以-p选项应该为-p tcp 或 -p udp
2. -p all 这个all参数是否可 ...


把all替换为tcp,执行
iptables -I INPUT -p tcp --dport http -j fail2ban-Apache

没有出错

这个all是在fail2ban.conf里面定义的

# Option:  protocol
# Notes.:  internally used by config reader for interpolations.
# Values:  [ tcp | udp | icmp | all ] Default: tcp
#
protocol = tcp

[ 本帖最后由 arbor 于 2008-8-13 10:14 编辑 ]

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
6 [报告]
发表于 2008-08-13 11:00 |只看该作者
原帖由 arbor 于 2008-8-13 10:10 发表


把all替换为tcp,执行
iptables -I INPUT -p tcp --dport http -j fail2ban-Apache

没有出错

这个all是在fail2ban.conf里面定义的



呵呵,我记得标准iptables里面没有all的这个参数。另外,http链接属于TCP,所以-p tcp就可以。

现在LZ的问题解决了没有?

论坛徽章:
0
7 [报告]
发表于 2008-08-14 14:57 |只看该作者
原帖由 Godbach 于 2008-8-13 11:00 发表


呵呵,我记得标准iptables里面没有all的这个参数。另外,http链接属于TCP,所以-p tcp就可以。

现在LZ的问题解决了没有?


估计是ok了,看fail2ban的日志:

2008-08-13 17:53:10,738 WARNING: SSH: Ban (600 s) 121.8.140.90
2008-08-13 18:03:10,752 WARNING: SSH: Unban 121.8.140.90
2008-08-13 19:04:28,299 WARNING: SSH: Ban (600 s) 195.189.140.13
2008-08-13 19:14:29,222 WARNING: SSH: Unban 195.189.140.13
2008-08-14 09:05:56,312 WARNING: SSH: Ban (600 s) 67.202.0.246
2008-08-14 09:15:57,270 WARNING: SSH: Unban 67.202.0.246


非常感谢!

论坛徽章:
1
双子座
日期:2014-09-25 13:38:50
8 [报告]
发表于 2009-04-01 11:45 |只看该作者

回复 #1 arbor 的帖子

请问您这个在jail.conf里面是如何配置的 ?我刚安装了fail2ban ,也需要做这样的工作

谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP