CentOS 7.xで空いているポートを調べる

カテゴリ: Linux | タグ:

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しているポートも表示されます。


Amazonでおトクに買い物する方法
AmazonチャージでポイントGET


Amazonは買いもの前にAmazonギフト券をチャージしてポイントをゲットしないと損!

こちらもおススメ

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です