4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MacでTCP/UDPポートを開いているアプリを確認する

Posted at

OSに標準で付属しているlsofコマンドを使用する。
-iオプションを使用すると、対象のプロトコルやポート番号を指定できる。
たとえば、TCPの443ポートを使用しているアプリを調べるには、以下のように入力する。
lsof -iTCP:443

以下のような感じで結果が表示され、この例ではDropboxがd.v.dropbox.com:443にアクセスしていることが分かる。

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Dropbox 694 hoge 34u IPv4 0x5db8a84b2cd36acf 0t0 TCP 192.168.xxx.xxx:51743->d.v.dropbox.com:https (ESTABLISHED)

このままでも目的は達成できるが、IPアドレスから名前を引きにいったり、ポート番号がサービス名に置換されるため、結果が表示されるまでに時間がかかる。
lsof -n -P -iTCP:443
とすると置換処理が抑制されて結果がスグに表示される。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?