TCPポートを開いているプロセスを確認する
TCPポートを開いているプロセスを確認するには、netstat コマンドでオプションに -tanp を指定します。
# netstat -tanp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:901 0.0.0.0:* LISTEN 2411/xinetd tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN 2374/snmpd tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2647/mysqld tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 2940/smbd tcp 0 0 0.0.0.0:683 0.0.0.0:* LISTEN 2197/rpc.statd tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2157/portmap tcp 0 0 127.0.0.1:54321 0.0.0.0:* LISTEN 3107/avgtcpd tcp 0 0 127.0.0.1:54322 0.0.0.0:* LISTEN 3107/avgtcpd tcp 0 0 0.0.0.0:4949 0.0.0.0:* LISTEN 2794/munin-node tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 2470/vsftpd tcp 0 0 192.168.xx.xxx:53 0.0.0.0:* LISTEN 2129/named tcp 0 0 192.168.xx.xxx:53 0.0.0.0:* LISTEN 2129/named tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 2129/named tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2747/master tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 2129/named tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 2940/smbd tcp 0 0 192.168.xx.xxx:445 192.168.xx.xxx:49159 ESTABLISHED 2423/smbd tcp 0 0 192.168.xx.xxx:445 192.168.xx.xxx:49156 ESTABLISHED 2089/smbd tcp 0 0 192.168.xx.xxx:445 192.168.xx.xxx:49160 ESTABLISHED 4154/smbd tcp 0 0 :::80 :::* LISTEN 12254/httpd tcp 0 0 :::22 :::* LISTEN 2392/sshd tcp 0 0 :::443 :::* LISTEN 12254/httpd tcp 0 0 ::ffff:192.168.xx.xxx:22 ::ffff:192.168.xx.xxx:49401 ESTABLISHED 2810/0 tcp 0 0 ::ffff:192.168.xx.xxx:22 ::ffff:192.168.xx.xxx:65043 ESTABLISHED 11976/1
なお、今回使用した netstatコマンド オプションの詳細を以下に記載します。
◆netstatコマンド オプション一覧
-a 全てのソケットを表示する。 -n ホスト名などを解決せずに数字で表示する。 -p 各ソケットを利用しているプログラムのプロセスIDを表示する。 -t | -u | -w TCP(「-t」)、UDP(「-u」)、そのほかIPとICMP(「-w」)のみ表示する。
[対象]
CentOS 5.x
CentOS 6.x