I'm trying to investigate why the amounts of connections between two physical hosts и (CentOS 6) don't match each other (diagnosed from the each one respectively):


$ sudo netstat -lnpa | grep tcp | grep ESTABLISHED | grep | wc -l



$ sudo netstat -lnpa | grep tcp | grep ESTABLISHED | grep | wc -l


Why is it possible at all? I guess there is a connection leak on the side of, but how to find out which software is leaking?

  • 1
    I too often use wc -l and then have to step back and compare the output directly to identify the problem - so how do these 54 compared to the 189 lines do look like. They should carry all relevant info like process name etc ... – Dilettant May 31 '16 at 21:03

Try looking at the output without the wc -l. The pattern '' matches 11 addresses. You may want a pattern like ^tcp.**ESTABLISED which reduces the number of commands required.

You don't need sudo nor all the netstat options. Try a command like:

netstat -nt | grep `^tcp.**ESTABLISED` | wc -l

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.