解决方法:top 显示所有的httpd进程。
选取进程中占用mem%多的,用lsof -p pid 来查看,如果有3-4个httpd进程都显示同一个网站,则基本上可以判定该网站就是问题网站!
见附件
日志中内容如下:显然是针对一个网页的访问!
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:45 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
- www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
3:linux下防止SYN Flood攻击,能够有效防范SYN Flood攻击的手段之一,就是SYN Cookie,
三:Linux下设置
如果你的服务器配置不太好,TCP TIME_WAIT套接字数量达到两、三万,服务器很容易被拖死。通过修改Linux内核参数,可以减少服务器的TIME_WAIT套接字数量。
TIME_WAIT可以通过以下命令查看:
以下是代码片段: netstat -an | grep "TIME_WAIT" | wc -l |
在Linux下,如CentOS,可以通过修改/etc/sysctl.conf文件来达到目的。
增加以下几行:
以下是代码片段: net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_max_syn_backlog = 8192 net.ipv4.tcp_max_tw_buckets = 5000 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 2 |
说明:
net.ipv4.tcp_syncookies = 1 表示开启SYN Cookies,这是个BOOLEAN。当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击,默认为0,表示关闭;
net.ipv4.tcp_tw_reuse = 1 表示开启重用,这是个BOOLEAN。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭;
net.ipv4.tcp_tw_recycle = 1 表示开启TCP连接中TIME-WAIT sockets的快速回收,这是个BOOLEAN,默认为0,表示关闭。
net.ipv4.tcp_fin_timeout = 30 表示如果套接字由本端要求关闭,这个参数决定了它保持在FIN-WAIT-2状态的时间。单位为秒。
net.ipv4.tcp_keepalive_time = 1200 表示当keepalive起用的时候,TCP发送keepalive消息的频度。缺省是2小时,改为20分钟。单位为秒。
net.ipv4.ip_local_port_range = 1024 65000 表示用于向外连接的端口范围。缺省情况下很小:32768到61000,改为1024到65000。
net.ipv4.tcp_max_syn_backlog = 8192 表示SYN队列的长度,默认为1024,加大队列长度为8192,可以容纳更多等待连接的网络连接数。
net.ipv4.tcp_max_tw_buckets = 5000 表示系统同时保持TIME_WAIT套接字的最大数量,如果超过这个数字,TIME_WAIT套接字将立刻被清除并打印警告信息。默认为180000,改为5000。对于Apache、Nginx等服务器,上几行的参数可以很好地减少TIME_WAIT套接字数量,但是对于Squid,效果却不大。此项参数可以控制TIME_WAIT套接字的最大数量,避免Squid服务器被大量的TIME_WAIT套接字拖死。
net.ipv4.tcp_synack_retries和net.ipv4.tcp_syn_retries是定义SYN重试次数。
执行以下命令使配置生效:
如果你不想修改/etc/sysctl.conf,你也可以直接使用命令修改:
以下是代码片段: /sbin/sysctl -w key=value |
4: 四:FreeBSD下设置
参数设置参考:
以下是引用片段:
net.inet.tcp.syncookies=1 防止DOS攻击
net.inet.tcp.msl=7500 防止DOS攻击,默认为30000
net.inet.tcp.blackhole=2 接收到一个已经关闭的端口发来的所有包,直接drop,如果设置为1则是只针对TCP包
net.inet.udp.blackhole=1 接收到一个已经关闭的端口发来的所有UDP包直接drop |
阅读(2212) | 评论(0) | 转发(0) |