首页 > 代码库 > netstat大量time_wait连接

netstat大量time_wait连接

http://chembo.iteye.com/blog/1503770

http://www.2cto.com/os/201007/54067.html

http://blog.csdn.net/dacong/article/details/50485585

 

 主动关闭一方会进入一个TIME_WAIT的中间状态. 通过netstat 查看到的内容如下:

tcp 0 0 10.19.67.11:40184 10.19.67.11:7012 TIME_WAIT
tcp 0 0 10.19.67.11:39167 10.19.67.11:7012 TIME_WAIT

是 40184的端口主动关闭,处于TIME_WAIT状态。

 

检查一下time wait的值:

1 [root@vFStor-1RTqI ~]# sysctl -a | grep time | grep wait
2 net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
3 net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
4 net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
5 [root@vFStor-1RTqI ~]# 

 

检查net.ipv4.tcp_tw当前值:

1 [root@vFStor-1RTqI ~]# sysctl -a|grep net.ipv4.tcp_tw
2 net.ipv4.tcp_tw_recycle = 0
3 net.ipv4.tcp_tw_reuse = 0
4 [root@vFStor-1RTqI ~]#

 

修改 /etc/sysctl.conf 配置文件,添加内容。

重新生效sysctl.conf 配置文件:

 1 [root@vFStor-1RTqI ~]# sysctl -p
 2 net.ipv4.ip_forward = 0
 3 net.ipv4.conf.default.rp_filter = 1
 4 net.ipv4.conf.default.accept_source_route = 0
 5 kernel.sysrq = 0
 6 kernel.core_uses_pid = 1
 7 net.ipv4.tcp_syncookies = 1
 8 net.bridge.bridge-nf-call-ip6tables = 0
 9 net.bridge.bridge-nf-call-iptables = 0
10 net.bridge.bridge-nf-call-arptables = 0
11 net.ipv4.tcp_tw_reuse = 1
12 net.ipv4.tcp_tw_recycle = 1

 

netstat大量time_wait连接