I write a buggy server to leak socket fd, which listen on 5000, and as expected there were CLOSE-WAIT left when client is closed
$ ss -ntpa | grep 5000
LISTEN 0 50 :::5000 :::* users:(("java",14586,92))
CLOSE-WAIT 79 0 ::ffff:127.0.0.1:5000 ::ffff:127.0.0.1:55804 users:(("java",14586,96))
CLOSE-WAIT 79 0 ::ffff:127.0.0.1:5000 ::ffff:127.0.0.1:59235 users:(("java",14586,93))
CLOSE-WAIT 5 0 ::ffff:127.0.0.1:5000 ::ffff:127.0.0.1:55803 users:(("java",14586,95))
CLOSE-WAIT 150 0 ::ffff:127.0.0.1:5000 ::ffff:127.0.0.1:59236 users:(("java",14586,94))
Then I try to reuse one of those badly-bebaved socket like this:
# to listen what on earth send
$ sudo tcpdump -i any src port 55803 or dst port 55803 -SvvvA -w /tmp/test.pcap
# then
$ time nc -p 55803 localhost 5000
The result of nc
command is nothing within 2min
$ time nc -p 59236 localhost 5000
nc: connect to localhost port 5000 (tcp) failed: Connection timed out
real 2m7.282s
user 0m0.000s
sys 0m0.001s
And I open test.pcap via wireshark, it shows TCP Retransmission happened 6 times and the server responsed nothing.
iptables is completely off on my box.