Get the App
SLTechnology News&Howtos  ›  Network Security  › 

In TIME_WAIT, the bind port will fail after modifying the socket option

Shulou Source: shulou.com Published: 2022-06-01 07:19:06 11月26日 Update

In TIME_WAIT, the bind port will fail after modifying the socket option, even if you are using SO_REUSEADDR or SO_REUSEPORT mode

* *

Tcp 0 0 127.0.0.1:81 127.0.0.1:56850 TIME_WAIT

* *

Tcp 0 0 127.0.0.1:81 127.0.0.1:56850 TIME_WAIT

* *

Tcp 0 0 127.0.0.1:81 127.0.0.1:56850 TIME_WAIT

* *

Tcp 0 0 127.0.0.1:81 127.0.0.1:56850 TIME_WAIT

As mentioned above, after the process exits, as long as TIME_WAIT still exists (only disappears after 2MSL), switching the socket option to the bind port will not be successful, such as SO_REUSEADDR and SO_REUSEPORT mode change.

The solution is to set all three variables of tcp_timestamp,tcp_reuse,tcp_recycle to 1 so that TIME_WAIT can be quickly recycled after the process exits.

Tags: Port mode process switch state success three two variables as above that is method change Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MySQL Microsoft NVidia Shulou Technology