CentOS7で空いているポートはssコマンド(socket statistics)で確認できます。
TCPポートを確認したい場合は以下のようにコマンドを実行すれば良いです。
この例ではPort80, 22, 25, 3031, 3032がオープンしています
$ ss -nat
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 :::3031 :::*
LISTEN 0 128 :::3032 :::*
上記例で指定している-nat
の、各オプションの意味は下記の通りです。
NAME
ss - another utility to investigate sockets
SYNOPSIS
ss [options] [ FILTER ]
DESCRIPTION
ss is used to dump socket statistics. It allows showing information similar to netstat.
It can display more TCP and state informations than other tools.
OPTIONS
When no option is used ss displays a list of open non-listening sockets
(e.g. TCP/UNIX/UDP) that have established connection.
-a, --all
Display both listening and non-listening
(for TCP this means established connections) sockets.
-n, --numeric
Do not try to resolve service names.
-t, --tcp
Display TCP sockets.
オプションに-nt
指定するとすでに接続が確立しているポートのみが表示され、-nat
だとlistenしているポートも表示されます。
こちらもおススメ