netstat/ss shows duplicated outgoing time_wait sockets

855 views Asked by At

I encountered this behaviour many times in many servers which processed lots of network connections.

    # ss -nt state time-wait sport ne :80 and sport ne :10050 | sort -k3 
    0      0                      127.0.0.1:13530                 127.0.0.1:8888
    0      0                      127.0.0.1:21978                 127.0.0.1:8080
    0      0                      127.0.0.1:32490                 127.0.0.1:8080
    0      0                      127.0.0.1:42922                 127.0.0.1:8080
    0      0                      127.0.0.1:50728                 127.0.0.1:8080
    0      0                      127.0.0.1:51542                 127.0.0.1:8888
    0      0                      127.0.0.1:6274                  127.0.0.1:8888
    0      0                      127.0.0.1:65264                 127.0.0.1:8888
    0      0                  172.16.40.100:10000               172.16.40.5:3010
    0      0                  172.16.40.100:10002              172.16.40.34:3010
    0      0                  172.16.40.100:10002              172.16.40.97:3020
    0      0                  172.16.40.100:10004             172.16.40.116:3010
    0      0                  172.16.40.100:10004              172.16.40.21:3010
    0      0                  172.16.40.100:10008              172.16.40.30:3010
    0      0                  172.16.40.100:10010             172.16.40.216:3020
    0      0                  172.16.40.100:10012              172.16.40.30:3010
    0      0                  172.16.40.100:10014             172.16.40.131:3010
    0      0                  172.16.40.100:10014              172.16.40.22:3010
    0      0                  172.16.40.100:10014              172.16.40.33:3010

This is a part of ss output. As you may see, there are several strings with duplicated outgoing time_wait sockets. Such as:

    0      0                  172.16.40.100:10002              172.16.40.34:3010
    0      0                  172.16.40.100:10002              172.16.40.97:3020

or

    0      0                  172.16.40.100:10014             172.16.40.131:3010
    0      0                  172.16.40.100:10014              172.16.40.22:3010
    0      0                  172.16.40.100:10014              172.16.40.33:3010

I googled this question but could not get a reasonable explanation of this topic.

Thanks a lot!

1

There are 1 answers

0
user207421 On

As you may see, there are several strings with duplicated outgoing time_wait sockets. Such as:

0      0                  172.16.40.100:10002              172.16.40.34:3010
0      0                  172.16.40.100:10002              172.16.40.97:3020

or

0      0                  172.16.40.100:10014             172.16.40.131:3010
0      0                  172.16.40.100:10014              172.16.40.22:3010
0      0                  172.16.40.100:10014              172.16.40.33:3010

The lines in this display are connections, not sockets. There are exactly zero 'duplicated sockets' here. There is a duplicated port, because at the server end the port is always the same. However either the client IP address or the client port is always different. Or both.