読者です 読者をやめる 読者になる 読者になる

みーのぺーじ

みーが趣味でやっているPCやソフトウェアについて.Unity, Python, Processingなどのプログラミングや,脱獄, hackintoshなど

トップ / 記事一覧 / カテゴリ

ネットワークの接続状況を取得する

OS X (Mac)

どんなプロセスがどこのサーバーと接続しているかを調べるには,lsofコマンドを使うのが便利です.

現在のネットワーク接続状況を表示する.lsof -i

-iオプションで,ネットワークの接続状況を表示します.

xxxxxxxx$ lsof -i
COMMAND    PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
UserEvent  239 xxxxxxxx    4u  IPv4 0x1c0123f9b9bcc3b9      0t0  UDP *:*
sharingd   275 xxxxxxxx   12u  IPv4 0x1c0123f9b9bceb91      0t0  UDP *:*
WiFiAgent  349 xxxxxxxx   16u  IPv4 0x1c0123f9b9bcbf09      0t0  UDP *:*
Dropbox    361 xxxxxxxx   31u  IPv4 0x1c0123f9d3a061c1      0t0  TCP 192.168.1.2:51318->snt-re3-6b.sjc.dropbox.com:http (ESTABLISHED)
Dropbox    361 xxxxxxxx   36u  IPv4 0x1c0123f9b9bcdb29      0t0  UDP *:17500
Dropbox    361 xxxxxxxx   39u  IPv4 0x1c0123f9c06fac31      0t0  TCP *:17500 (LISTEN)
plugin_ho  747 xxxxxxxx   27u  IPv4 0x1c0123f9ba108dd1      0t0  TCP 192.168.1.2:50189->209-20-75-76.slicehost.net:http (CLOSE_WAIT)
Google     897 xxxxxxxx   70u  IPv4 0x1c0123f9d3ba2dd1      0t0  TCP 192.168.1.2:55146->tb-in-f189.1e100.net:https (ESTABLISHED)
Google     897 xxxxxxxx   94u  IPv4 0x1c0123f9d3ba7dd1      0t0  TCP 192.168.1.2:55447->nrt13s01-in-f21.1e100.net:https (ESTABLISHED)
Google     897 xxxxxxxx  125u  IPv4 0x1c0123f9d3ba1c31      0t0  TCP 192.168.1.2:54327->tg-in-f188.1e100.net:5228 (ESTABLISHED)
firefox    909 xxxxxxxx   58u  IPv4 0x1c0123f9d3a64021      0t0  TCP 192.168.1.2:55429->nrt13s01-in-f17.1e100.net:https (ESTABLISHED)
firefox    909 xxxxxxxx   74u  IPv4 0x1c0123f9bbcffdd1      0t0  TCP 192.168.1.2:55436->ec2-54-64-43-213.ap-northeast-1.compute.amazonaws.com:http (ESTABLISHED)
iTunes     999 xxxxxxxx   41u  IPv4 0x1c0123f9c0305a91      0t0  TCP *:daap (LISTEN)
iTunes     999 xxxxxxxx   42u  IPv6 0x1c0123f9ba103251      0t0  TCP *:daap (LISTEN)
iTunes     999 xxxxxxxx   55u  IPv4 0x1c0123f9d3a0d501      0t0  TCP 192.168.1.2:53804->s3-external-1.amazonaws.com:https (CLOSE_WAIT)
iTunes     999 xxxxxxxx   56u  IPv4 0x1c0123f9d3a0d501      0t0  TCP 192.168.1.2:53804->s3-external-1.amazonaws.com:https (CLOSE_WAIT)
iTunes     999 xxxxxxxx   60u  IPv4 0x1c0123f9d3a08dd1      0t0  TCP 192.168.1.2:53355->s3-external-1.amazonaws.com:https (CLOSED)
iTunes     999 xxxxxxxx   61u  IPv4 0x1c0123f9d3a08dd1      0t0  TCP 192.168.1.2:53355->s3-external-1.amazonaws.com:https (CLOSED)
iTunes     999 xxxxxxxx   63u  IPv4 0x1c0123f9d3a0ba91      0t0  TCP 192.168.1.2:53535->s3-external-1.amazonaws.com:https (CLOSED)
iTunes     999 xxxxxxxx   70u  IPv4 0x1c0123f9d3a0ba91      0t0  TCP 192.168.1.2:53535->s3-external-1.amazonaws.com:https (CLOSED)
Safari    1103 xxxxxxxx   44u  IPv4 0x1c0123f9d3a07c31      0t0  TCP 192.168.1.2:55418->nrt13s01-in-f5.1e100.net:https (ESTABLISHED)
Safari    1103 xxxxxxxx   46u  IPv4 0x1c0123f9d3a07c31      0t0  TCP 192.168.1.2:55418->nrt13s01-in-f5.1e100.net:https (ESTABLISHED)
Safari    1103 xxxxxxxx   47u  IPv4 0x1c0123f9d3a17501      0t0  TCP 192.168.1.2:55419->nrt13s01-in-f7.1e100.net:https (ESTABLISHED)
Safari    1103 xxxxxxxx   48u  IPv4 0x1c0123f9d3a17501      0t0  TCP 192.168.1.2:55419->nrt13s01-in-f7.1e100.net:https (ESTABLISHED)

2秒おきに更新する.lsof -r 2 -a -i

オプションの詳細はこちら

このコマンドはいろいろと便利です.