Para ver cuantas conexiones tenemos activas
|
1 |
netstat -nat | awk '{print $6}' | sort | uniq -c | sort -n |
Se imprime algo asi:
1 established)
1 Foreign
3 FIN_WAIT2
5 LAST_ACK
6 CLOSING
9 SYN_RECV
10 ESTABLISHED
22 FIN_WAIT1
26 LISTEN
466 TIME_WAIT
Para mirar la configuracion actual:
|
1 2 3 |
cat /proc/sys/net/ipv4/tcp_fin_timeout cat /proc/sys/net/ipv4/tcp_tw_recycle cat /proc/sys/net/ipv4/tcp_tw_reuse |
Los valores por defecto son: 60, 0 and 0. Los cambiaremos por: 30, 1, 1.
|
1 2 |
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse |
|
1 2 |
#Este parametro tiene problemas cuando hay NAT echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle |
Para que los cambies queden persistentes, debemos cambiar /etc/sysctl.conf colocando las siguientes lineas al final
|
1 2 3 4 5 6 |
# Decrease TIME_WAIT seconds net.ipv4.tcp_fin_timeout = 30 # Recycle and Reuse TIME_WAIT sockets faster net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 |
Para incrementar los limites de los puertos que pueden ser usados:
|
1 2 3 4 5 6 |
echo 1024 65535 > /proc/sys/net/ipv4/ip_local_port_range nano /etc/sysctl.conf # increase system IP port limits net.ipv4.ip_local_port_range = 1024 65535 |
Listo.