In CentOS 6 w/ OpenVZ 2.6.32, this command outputs IPs with the highest number of connections against port 22, e.g:

[root@legovz ~]# netstat -antu | grep :22 | grep -v LISTEN | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

Under CentOS 7, w/ OpenVZ 7, the output is always as follows, despite the fact I know there is lots of traffic on port 22:

[root@ovz7 ~]# netstat -antu | grep :22 | grep -v LISTEN | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
[root@ovz7 ~]#

What I need to do differently, to achieve the same result with CentOS 7.? If I can't, why?

  • 1
    That command seems to be working for me on OpenVZ 7 and CentOS 7, showing the foreign address of any established connections on port 22 with the remote port stripped out. If you are still having issues, try your command with less piped commands and see where your issue may lie. Make sure you note that CentOS/RedHat have deprecated net-tools and netstat so they may not be available on related distros in the future. – GracefulRestart Apr 9 at 17:45
  • Even when stripping down the command, the output is minimal: [root@ovz7 ~]# netstat -antu | grep :22 udp 0 0* [root@ovz7 ~]# Which is strange because there's lots of SSH connections, all of which are on port 22. [root@ovz7 ~]# ps aux | grep ssh | wc -l 315 [root@ovz7 ~]# – jones8u5kf Apr 9 at 19:32

Your Answer

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

Browse other questions tagged or ask your own question.