Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2809277
  • 博文数量: 587
  • 博客积分: 6356
  • 博客等级: 准将
  • 技术积分: 6410
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-23 10:54
个人简介

器量大者,福泽必厚

文章分类

全部博文(587)

文章存档

2019年(3)

2018年(1)

2017年(29)

2016年(39)

2015年(66)

2014年(117)

2013年(136)

2012年(58)

2011年(34)

2010年(50)

2009年(38)

2008年(16)

分类: LINUX

2011-08-29 10:55:48

 2011-08-29_085200.JPG    2011-08-29_101707.JPG    2011-08-29_101726.JPG   场景:机器负载很高,top显示时有268,见附件,正常时机器负载大概有0---5 ,查看httpd进程数,ps aux | grep httpd |wc -l  大概有300多个, 正常情况下httpd个数50---75个
解决方法:top 显示所有的httpd进程。
选取进程中占用mem%多的,用lsof -p pid 来查看,如果有3-4个httpd进程都显示同一个网站,则基本上可以判定该网站就是问题网站!
 见附件
日志中内容如下:显然是针对一个网页的访问!
  1. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:45 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  2. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  3. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  4. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  5. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  6. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  7. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  8. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  9. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  10. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  11. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  12. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  13. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  14. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  15. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  16. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  17. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  18. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  19. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  20. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  21. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  22. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  23. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  24. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  25. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  26. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  27. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  28. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  29. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:46 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  30. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  31. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  32. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  33. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  34. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  35. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  36. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  37. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  38. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  39. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  40. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  41. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  42. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  43. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  44. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  45. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  46. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  47. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  48. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  49. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  50. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  51. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  52. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  53. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  54. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  55. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  56. www.*******.com 95.130.128.164 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  57. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  58. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  59. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  60. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  61. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  62. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  63. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  64. www.*******.com 188.232.8.176 - - [29/Aug/2011:10:26:47 +0800] "GET /team.php?id=26 HTTP/1.1" 404 -
  65. 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重试次数。

  执行以下命令使配置生效:

以下是代码片段:
 /sbin/sysctl -p

    如果你不想修改/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) |
0

上一篇:open_basedir restriction

下一篇:internal 500 error

给主人留下些什么吧!~~