linux – 如何摆脱FIN_WAIT1状态的套接字?

前端之家收集整理的这篇文章主要介绍了linux – 如何摆脱FIN_WAIT1状态的套接字?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个被我需要杀死的进程阻止的端口. (一个崩溃的小telnet守护进程).
该进程已成功终止,但该端口仍处于“FIN_WAIT1”状态.它没有出来,它的超时似乎被设置为“十年”.

我发现释放端口的唯一方法是重启整个机器,这是我不想做的事情.

  1. $netstat -tulnap | grep FIN_WAIT1
  2. tcp 0 13937 10.0.0.153:4000 10.0.2.46:2572 FIN_WAIT1 -

有没有人知道如何在不重新启动的情况下解锁此端口?

解决方法

  1. # record what tcp_max_orphans's current value
  2. original_value=$(cat /proc/sys/net/ipv4/tcp_max_orphans)
  3.  
  4. #set the tcp_max_orphans to 0 temporarily
  5. echo 0 > /proc/sys/net/ipv4/tcp_max_orphans
  6.  
  7. # watch /var/log/messages
  8. # it will split out "kernel: TCP: too many of orphaned sockets"
  9. # it won't take long for the connections to be killed
  10.  
  11. # restore the value of tcp_max_orphans whatever it was before.
  12. echo $original_value > /proc/sys/net/ipv4/tcp_max_orphans
  13.  
  14. # verify with
  15. netstat -an|grep FIN_WAIT1

猜你在找的Linux相关文章