Sometimes you need to know what your server is serving.
That is, what applications or programs are running on the server that are accessed over the network and what port are they listening on.
I’m used to netstat on Windows, lets give that a try
[root@homeserver hassconfig]# netstat -a -bash: netstat: command not found
OK, so lets
https://www.google.com/search?q=centos+netstat
Which first result gives me
https://unix.stackexchange.com/questions/146190/commands-not-found-netstat-nmap-on-centos-7
It seems on CentOS7 the classic netstat has been replaced by the iproute2 suite. Thanks slm.
So we now have a list of CentOS 7 networking commands
Deprecated Linux networking commands and their replacements
How to view just listening ports using ss
https://www.google.com/search?q=ss+listening+ports
which gives me
https://www.linux.com/learn/intro-to-linux/2017/7/introduction-ss-command
And in the excellent article i can see the command i need
[root@homeserver hassconfig]# ss -4 state listening Netid Recv-Q Send-Q Local Address:Port Peer Address:Port tcp 0 128 *:8123 *:* tcp 0 50 *:microsoft-ds *:* tcp 0 50 *:netbios-ssn *:* tcp 0 128 *:ssh *:* tcp 0 100 127.0.0.1:smtp *:*
This tells me on IPv4 my server is listening on ports 8123, 445 (microsoft-ds), 139 (netbios-ssn), 22 (ssh) and (probably) 25 (smtp) on the loopback interface.
One thought on “How to check listening ports on CentOS”
Comments are closed.