28
23

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でネットワークインターフェイスに割り当てられたIPアドレスを調べる方法

Posted at

MacBookなどでWiFiに接続しつつ、LANケーブルを繋ぎこむとネットワークインターフェイスが複数できる。本稿では、このようなシーンでそれぞれのネットワークインターフェイスに当っているIPアドレスを調べる方法を説明する。

ネットワークハードウェアのリストを出す

networksetupコマンドを使うと、Macのネットワークハードウェアを一覧できる。出力のDeviceの値がifconfigのネットワークインターフェイス名と一致する。

$ networksetup -listallhardwareports

Hardware Port: Thunderbolt Ethernet
Device: en8
Ethernet Address: a8:20:66:24:d4:3f

Hardware Port: Wi-Fi
Device: en0
Ethernet Address: dc:a9:04:78:61:8b

Hardware Port: Bluetooth PAN
Device: en6
Ethernet Address: dc:a9:04:73:dc:65

Hardware Port: Thunderbolt 1
Device: en1
Ethernet Address: aa:00:c9:08:ec:01

Hardware Port: Thunderbolt 2
Device: en2
Ethernet Address: aa:00:c9:08:ec:00

Hardware Port: Thunderbolt 3
Device: en3
Ethernet Address: aa:00:c9:08:ec:05

Hardware Port: Thunderbolt 4
Device: en4
Ethernet Address: aa:00:c9:08:ec:04

Hardware Port: Thunderbolt Bridge
Device: bridge0
Ethernet Address: aa:00:c9:08:ec:01

VLAN Configurations
===================

ネットワークインターフェイスに割り当てられたIPアドレスを調べる

割り当てられたIPを調べるにはifconfigコマンドを使う。networksetupコマンドで調べたインターフェイス名からIPアドレスを引く。

$ ifconfig en0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether dc:a9:04:78:61:8b
	inet6 fe80::148c:c32:e7bf:9bc%en0 prefixlen 64 secured scopeid 0x8
	inet 172.20.10.4 netmask 0xfffffff0 broadcast 172.20.10.15
	inet6 2001:240:241a:8c30:d2:6945:d5a1:6a33 prefixlen 64 autoconf secured
	inet6 2001:240:241a:8c30:1582:71cf:5eb2:ca6d prefixlen 64 autoconf temporary
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
$ ifconfig en8
en8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
	ether a8:20:66:24:d4:3f
	inet6 fe80::863:126f:5921:7e83%en8 prefixlen 64 secured scopeid 0x12
	inet 192.168.5.67 netmask 0xffffff00 broadcast 192.168.5.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect (1000baseT <full-duplex,flow-control,energy-efficient-ethernet>)
	status: active
28
23
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
28
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?