¿Es posible dar una conexión a cada IP?

¿Es posible dar una conexión a cada IP?

Tengo problemas de sobrecarga. Demasiadas conexiones y algunas IP tienen más de 20 conexiones a la vez. Hago este comando.

netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

Para obtener el total de conexiones y este es el resultado:

      1 106.3.98.81
      1 106.3.98.82
      1 108.171.251.2
      1 110.85.103.207
      1 111.161.30.217
      1 113.53.103.55
      1 119.235.237.20
      1 124.106.19.34
      1 157.55.32.166
      1 157.55.33.49
      1 157.55.34.28
      1 175.141.103.239
      1 180.76.5.59
      1 180.76.5.61
      1 188.235.165.216
      1 205.213.195.70
      1 216.157.222.25
      1 218.93.205.100
      1 222.77.209.105
      1 27.153.148.109
      1 27.159.194.242
      1 27.159.253.71
      1 54.242.122.201
      1 61.172.50.99
      1 65.55.24.239
      1 71.179.78.5
      1 74.125.136.27
      1 74.125.182.30
      1 74.125.182.36
      1 79.112.225.39
      1 93.190.139.208
      2 124.227.191.67
      2 157.55.33.84
      2 157.55.35.34
      2 190.66.3.107
      2 203.87.153.38
      2 220.161.119.3
      2 221.6.15.156
      2 27.153.148.116
      2 27.159.197.0
      2 96.47.224.42
      3 202.14.70.1
      3 218.6.15.42
      3 222.77.218.226
      3 222.77.224.187
      3 37.59.66.100
      3 46.4.181.244
      3 87.98.254.192
      3 91.207.8.62
      4 188.143.233.222
      4 218.108.168.166
      4 221.12.154.18
      4 93.182.157.8
      4 94.142.128.183
      5 180.246.170.187
      5 8.21.6.226
      6 178.137.94.87
      6 218.93.205.112
      7 199.15.234.222
      9
      9 125.253.97.6
     10 178.137.17.196
     11 46.118.192.179
     12 212.79.14.14
     21 72.201.187.135
     27 0.0.0.0

¿Alguien puede darme algunas indicaciones? Mi servidor falló varias veces esta semana debido a esto.

Gracias.

EDITAR:

Muy bien, mis registros de errores dicen:

[Thu Oct 18 12:17:39 2012] [error] could not make child process 4842 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4843 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4855 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4856 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4861 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4869 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4872 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4873 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4874 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4875 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4876 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4880 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4882 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4885 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4897 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4900 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4901 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4906 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4907 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4925 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4926 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4927 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4931 exit, attempting to continue anyway
[Thu Oct 18 12:17:40 2012] [notice] caught SIGTERM, shutting down
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613+lfs/curl.iso' - /usr/lib/php5/20060613+lfs/curl.iso: cannot open shared object file: No such file or directory in Unknown on line 0
[Thu Oct 18 12:17:45 2012] [notice] Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny10 with Suhosin-Patch configured -- resuming normal operations

Y tengo más de miles de líneas que dicen: (cada una tiene una identificación de proceso diferente)

[Thu Oct 18 12:17:38 2012] [error] child process 4906 still did not exit, sending a SIGKILL

Y también tengo una línea que dice:

[Wed Oct 17 09:44:58 2012] [error] server reached MaxClients setting, consider raising the MaxClients setting


<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 50
MaxClients 300
MaxRequestsPerChild 5000
</IfModule>

Respuesta1

Ese comando ignora el estado de la conexión. El siguiente comando solo muestra las conexiones en el ESTABLISHEDestado.

netstat -anp |grep 'tcp\|udp' | awk '/ESTABLISHED/ {print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

Éste los agrupa y agrega:

netstat -tn | awk '/tcp/ {print $5, $6}' | sed 's/:[^ ]*//' | sort | uniq -c | sort -n

Un par de preguntas más:

  1. ¿Qué quieres decir con "mi servidor falló"? ¿Reiniciar el sistema operativo? ¿Apache no responde? Exactamentequé pasó.
  2. ¿Cómo sabes que la cantidad de conexiones fue lo que causó el "bloqueo"? Si recibe un mensaje de error que dice "Demasiadas conexiones; abortando". eso sería bueno. Si no, investiguemos antes de sacar conclusiones precipitadas.

información relacionada