#navi(../)

* リッスンしているポートと接続しているIPとポートを調べる [#g07c5665]
netstatコマンドを利用してリッスン(LISTEN)しているポートと接続状態のIPとポート(ESTABLISHED)を調べる方法を以下に記します。~
いつも当方が調べる方法なので、不要なオプションもあるかもしれませんのでご了承を。

#contents
#htmlinsertpcsp(linux_ads_top.html,linux-sp.html)

* netstatコマンドで調べる [#af71b57d]
netstatコマンドに-ant引数を与えることによりリッスンと接続状態を調べることができます。
 netstat -ant

-実行例(一般ユーザで確認しました)
 $ netstat -ant
 Active Internet connections (servers and established)
 Proto Recv-Q Send-Q Local Address               Foreign Address             State      
 tcp        0      0 0.0.0.0:23456               0.0.0.0:*                   LISTEN      
 tcp        0      0 127.0.0.1:2208              0.0.0.0:*                   LISTEN      
 tcp        0      0 0.0.0.0:810                 0.0.0.0:*                   LISTEN      
 tcp        0      0 127.0.0.1:3310              0.0.0.0:*                   LISTEN      
 tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      
 tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      
 tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      
 tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      
 tcp        0      0 127.0.0.1:2207              0.0.0.0:*                   LISTEN      
 tcp        0      0 172.xxx.xxx.xxx:41258        172.xxx.xxx.xxx:143        ESTABLISHED 
 <snip>
 tcp        0      0 172.xxx.xxx.xxx:55325        172.xxx.xxx.xxx:8080        ESTABLISHED 
 tcp        0      0 :::22                       :::*                        LISTEN


ポート番号がわかり、どのプロセスがポートを利用しているかを調べたい場合は、以下の資料が参考になると思います。
- [[ポート番号から利用しているプロセスを調べる方法>逆引きUNIXコマンド/ポート番号から利用しているプロセスを調べる方法]]


以下のオプションで調べた場合は、プロセスも表示されます。
 netstat -nlp

-実行例(rootユーザで確認しました)
 # netstat -nlp
 Active Internet connections (only servers)
 Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
 tcp        0      0 0.0.0.0:23456               0.0.0.0:*                   LISTEN      26639/skype         
 tcp        0      0 127.0.0.1:2208              0.0.0.0:*                   LISTEN      2583/./hpiod        
 tcp        0      0 0.0.0.0:810                 0.0.0.0:*                   LISTEN      2324/rpc.statd      
 tcp        0      0 127.0.0.1:3310              0.0.0.0:*                   LISTEN      2623/clamd          
 tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      2285/portmap        
 tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2601/sshd           
 tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      2610/cupsd          
 tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      2643/sendmail       
 tcp        0      0 127.0.0.1:2207              0.0.0.0:*                   LISTEN      2588/python         
 tcp        0      0 :::22                       :::*                        LISTEN      2601/sshd           
 udp        0      0 0.0.0.0:23456               0.0.0.0:*                               26639/skype         
 udp        0      0 0.0.0.0:804                 0.0.0.0:*                               2324/rpc.statd      
 udp        0      0 0.0.0.0:807                 0.0.0.0:*                               2324/rpc.statd      
 udp        0      0 0.0.0.0:51630               0.0.0.0:*                               2751/avahi-daemon   
 udp        0      0 0.0.0.0:5353                0.0.0.0:*                               2751/avahi-daemon   
 udp        0      0 127.0.0.1:56045             0.0.0.0:*                               26639/skype         
 udp        0      0 0.0.0.0:111                 0.0.0.0:*                               2285/portmap        
 udp        0      0 0.0.0.0:631                 0.0.0.0:*                               2610/cupsd          
 udp        0      0 :::59352                    :::*                                    2751/avahi-daemon   
 udp        0      0 :::5353                     :::*                                    2751/avahi-daemon   
 Active UNIX domain sockets (only servers)
 Proto RefCnt Flags       Type       State         I-Node PID/Program name    Path
 unix  2      [ ACC ]     STREAM     LISTENING     10114  3012/scim-launcher  /tmp/scim-socket-frontend-sakura
 unix  2      [ ACC ]     STREAM     LISTENING     9326   2839/gdm-binary     /tmp/.gdm_socket
 unix  2      [ ACC ]     STREAM     LISTENING     5828   1940/iscsid         @ISCSIADM_ABSTRACT_NAMESPACE
 <snip>



* 関連資料 [#j06656b1]
- [[ポート番号から利用しているプロセスを調べる方法>逆引きUNIXコマンド/ポート番号から利用しているプロセスを調べる方法]]
- [[プロセスがどのポートを利用しているかを調べる方法>逆引きUNIXコマンド/プロセスがどのポートを利用しているかを調べる方法]]
#br
#htmlinsertpcsp(linux_ads_btm.html,linux-sp.html)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS