LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 3355|回复: 11

redhat 9被SYN floor攻击,怎么办

[复制链接]
发表于 2004-6-27 09:09:04 | 显示全部楼层 |阅读模式
这几天老是有人在攻击我的服务器,网站无法访问
用netstat -an 看一下,处于80端口有几千个syn recv的半连接状态,源ip是随机的.
dmsg 查看日志有很多如下的信息
possible SYN flooding on port 80. Sending cookies.
于是,在google里面搜索了此类贴子,按照一些精华贴上的建议设置了下面一些地方:
sysctl -w net.ipv4.icmp_echo_ignore_all=1
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
sysctl -w net.ipv4.tcp_max_syn_backlog="2048"
sysctl -w net.ipv4.tcp_synack_retries="3"

# SYN-Flooding Protection
# Create syn-flood chain for detecting Denial of Service attacks
iptables -N syn-flood
iptables -A INPUT -i eth0 -p tcp --syn -j syn-flood
# Limit 12 connections per second (burst to 24)
iptables -A syn-flood -m limit --limit 12/s --limit-burst 24 -j RETURN
iptables -A syn-flood -j DROP
这样,服务器可以访问了,但是速度还是比以前慢了N倍,打开一个html的页面都要10~20秒左右,php的更加慢,原来正常的时候1~2秒就可以出来的.
搞了一天,都没有搞定这个问题,LINUXSIR上的兄弟们快帮小弟一把,不然俺很快就要吃鱿鱼啦
^^^S.O.S~~~
发表于 2004-6-27 09:51:19 | 显示全部楼层
iptables -A INPUT -i eth0 -p tcp --syn -j syn-flood
# Limit 12 connections per second (burst to 24)
iptables -A syn-flood -m limit --limit 12/s --limit-burst 24 -j RETURN
这个地方可以试着该该:
iptbales -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT

兄弟的iptables完整的设置呢?
发表于 2004-6-27 09:59:49 | 显示全部楼层
论坛和网上都有很多iptables的防火墙脚本,还有就是网关最好和防火墙分离。。。。。

这样才不会sos。。。。
 楼主| 发表于 2004-6-27 11:22:56 | 显示全部楼层

胡乱配置的一个

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
RH-Lokkit-0-50-INPUT  all  --  anywhere             anywhere
syn-flood  tcp  --  anywhere             anywhere           tcp flags:SYN,RST,ACK/SYN
syn-flood  tcp  --  anywhere             anywhere           tcp flags:SYN,RST,ACK/SYN
syn-flood  tcp  --  anywhere             anywhere           tcp flags:SYN,RST,ACK/SYN

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
RH-Lokkit-0-50-INPUT  all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere           tcp flags:SYN,RST,ACK/SYN limit: avg 1/sec burst 5
ACCEPT     tcp  --  anywhere             anywhere           tcp flags:SYN,RST,ACK/SYN limit: avg 1/sec burst 5
ACCEPT     tcp  --  anywhere             anywhere           tcp flags:FIN,SYN,RST,ACK/RST limit: avg 1/sec burst 5
ACCEPT     icmp --  anywhere             anywhere           icmp echo-request limit: avg 1/sec burst 5

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain RH-Lokkit-0-50-INPUT (2 references)
target     prot opt source               destination
ACCEPT     udp  --  tempdns.guangzhou.gd.cn  anywhere           udp spt:domain dpts:1025:65535
ACCEPT     udp  --  dns.guangzhou.gd.cn  anywhere           udp spt:domain dpts:1025:65535
ACCEPT     udp  --  tempdns.guangzhou.gd.cn  anywhere           udp spt:domain dpts:1025:65535
ACCEPT     udp  --  dns.guangzhou.gd.cn  anywhere           udp spt:domain dpts:1025:65535
ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:ssh flags:SYN,RST,ACK/SYN
ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:http flags:SYN,RST,ACK/SYN
ACCEPT     tcp  --  anywhere             anywhere           tcp dpt:ftp flags:SYN,RST,ACK/SYN
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
REJECT     tcp  --  anywhere             anywhere           tcp dpts:0:1023 flags:SYN,RST,ACK/SYN reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             anywhere           tcp dpt:nfs flags:SYN,RST,ACK/SYN reject-with icmp-port-unreachable
REJECT     udp  --  anywhere             anywhere           udp dpts:0:1023 reject-with icmp-port-unreachable
REJECT     udp  --  anywhere             anywhere           udp dpt:nfs reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             anywhere           tcp dpts:x11:6009 flags:SYN,RST,ACK/SYN reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             anywhere           tcp dpt:xfs flags:SYN,RST,ACK/SYN reject-with icmp-port-unreachable

Chain syn-flood (3 references)
target     prot opt source               destination
REJECT     all  --  anywhere             anywhere           reject-with icmp-port-unreachable
RETURN     all  --  anywhere             anywhere           limit: avg 12/sec burst 24
DROP       all  --  anywhere             anywhere
RETURN     all  --  anywhere             anywhere           limit: avg 12/sec burst 24
DROP       all  --  anywhere             anywhere
发表于 2004-6-27 22:42:57 | 显示全部楼层
不是iptables - L
是脚本
 楼主| 发表于 2004-6-28 09:26:53 | 显示全部楼层

算了,这个问题我不继续探讨了,好难用纯软件的方法搞定,还是去培置硬件防火墙算了。

昨天试了下一个windows下面比较变态的syn flood攻击软件,测试了几个有名的网站,攻击80端口,速度开到最大,几乎是试一个,死一个啊,包括我们的linuxsir啊!郁闷ing...
发表于 2004-6-29 00:40:18 | 显示全部楼层
还是去培置硬件防火墙算了?


这个也是unix系统做的,朋友测试过几个硬件防火墙都是bsd的,才800的p3,强吧。。。。。。
发表于 2004-6-29 02:08:02 | 显示全部楼层
测试了几个有名的网站,攻击80端口,速度开到最大,几乎是试一个,死一个啊,包括我们的linuxsir啊!郁闷ing...


呵呵呵。。。。。。。。


觉得不会。。。兄弟如果用adsl上网,在你说的“测试”后,断开网络,再连接,再打开网站,你看到了什么..........

呵呵。。。。
发表于 2004-6-30 14:50:03 | 显示全部楼层
防火墙根本没用
在ddos面前只有拼硬件
谁的硬件够牛就水赢
发表于 2004-6-30 15:44:49 | 显示全部楼层
防火墙根本没用?没听说过,设置了峰值和syn过滤等,已经可以很好的去防了。。。。。


兄弟好像很不相信fw哦!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表