Mac で自分のネット内のネットワーク機器のip address と MAC address の対応を調べる。
Apple Store から X code をインストールしておく。
ターミナルで ip neigh というコマンドを使うわけだが、Mac にはインストールされていない。
Homebrew をインストールしておく。他のアプリのインストールにも使うから
$ ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)” < /dev/null 2> /dev/null
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following new directories will be created:
/usr/local/bin
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/sbin
/usr/local/share
/usr/local/var
/usr/local/opt
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var/homebrew
/usr/local/var/homebrew/linked
/usr/local/Cellar
/usr/local/Caskroom
/usr/local/Homebrew
/usr/local/Frameworks
==> The Xcode Command Line Tools will be installed.
==> /usr/bin/sudo /bin/mkdir -p /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
Password:
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown sigh /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/mkdir -p /Users/sigh/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/sigh/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown sigh /Users/sigh/Library/Caches/Homebrew
==> Searching online for the Command Line Tools
==> /usr/bin/sudo /usr/bin/touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
==> Installing Command Line Tools for Xcode-11.0
==> /usr/bin/sudo /usr/sbin/softwareupdate -i Command\ Line\ Tools\ for\ Xcode-11.0
Software Update Tool
Downloading Command Line Tools for Xcode
Downloaded Command Line Tools for Xcode
Installing Command Line Tools for Xcode
Done with Command Line Tools for Xcode
Done.
==> /usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
==> /usr/bin/sudo /usr/bin/xcode-select –switch /Library/Developer/CommandLineTools
==> Downloading and installing Homebrew…
HEAD is now at 3944416c4 Merge pull request #6666 from tanchihpin0517/master
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Tapping homebrew/core
Tapped 2 commands and 4861 formulae (5,118 files, 12.9MB).
Already up-to-date.
==> Installation successful!
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Next steps:
– Run `brew help` to get started
– Further documentation:
https://docs.brew.sh
あるいは
$ /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
インストールできたかどうかの確認は
$ brew doctor
Your system is ready to brew.
$
次に
brew tap brona/iproute2mac
brew install iproute2mac
を実行する。
$ brew tap brona/iproute2mac
Updating Homebrew…
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
minikube
==> Tapping brona/iproute2mac
Cloning into ‘/usr/local/Homebrew/Library/Taps/brona/homebrew-iproute2mac’…
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
Tapped (29 files, 24.6KB).
Teru-PBP:~ sigh$ brew install iproute2mac
==> Downloading https://github.com/brona/iproute2mac/releases/download/v1.2.3/ip
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws
######################################################################## 100.0%
🍺 /usr/local/Cellar/iproute2mac/1.2.3: 6 files, 22.5KB, built in 4 seconds
$ brew install iproute2mac
==> Downloading https://github.com/brona/iproute2mac/releases/download/v1.2.3/ip
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws
######################################################################## 100.0%
🍺 /usr/local/Cellar/iproute2mac/1.2.3: 6 files, 22.5KB, built in 4 seconds
ip と入力するとインストールできたことが確認される
$ ip
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
ip -V
where OBJECT := { link | addr | route | neigh }
OPTIONS := { -4 | -6 }
iproute2mac
Homepage: https://github.com/brona/iproute2mac
This is CLI wrapper for basic network utilities on Mac OS X inspired with iproute2 on Linux systems.
Provided functionality is limited and command output is not fully compatible with iproute2.
For advanced usage use netstat, ifconfig, ndp, arp, route and networksetup directly.
ip neigh と入力すると、ip address と MAC address の対応がわかる
$ ip neigh
fe80::1 dev lo0 lladdr (incomplete) REACHABLE
fe80::aede:48ff:fe00:1122 dev en5 lladdr ac:de:48:0:11:22 REACHABLE
略(ここにあるのは調査しているMacのネットワークインターフェースである。有線とかWiFiなど複数ある)
fe80::4392:a43b:2b69:78cf dev utun3 lladdr (incomplete) REACHABLE
169.254.139.233 dev en0 lladdr c:54:a5:55:e2:57 REACHABLE
169.254.252.102 dev en0 lladdr 0:16:eb:1b:8a:96 REACHABLE
192.168.xxx.1 dev en0 lladdr 0:a0:de:65:3f:b7 REACHABLE
192.168.xxx.2 dev en0 lladdr 3c:7:54:7d:ea:cc REACHABLE
192.168.xxx.102 dev en0 lladdr 54:33:cb:9:3e:6 REACHABLE
192.168.xxx.106 dev en0 lladdr c:51:1:80:8c:c6 REACHABLE
192.168.xxx.107 dev en0 lladdr 10:9a:dd:5b:4d:ed REACHABLE
略 (DHCP で配布しているのは192.168.xxx.101~192.168.xxx.200の範囲だ)
192.168.xxx.190 dev en0 lladdr c:54:a5:55:e2:57 REACHABLE
224.0.0.251 dev en0 lladdr 1:0:5e:0:0:fb REACHABLE
192.168.xxx.1 ~ 192.168.xxx.190 がルータの下に接続しているネトワーク機器だ。
MACアドレス検索でネットワーク機器のベンダーがわかる。
出力の 最初が 0 だと表示されていないから0を加えて検索する。
c:54:a5:55:e2:57 は 0c:54:a5:55:e2:57 のことだ。
3c:7:54:7d:ea:cc は 3c:07:54:7d:ea:cc のことだ。
最初の3デジット(aa:bb:cc)がメーカを示す。
ルーティングテーブルを読むということらしいけど、自分が持っているルーティングテーブルだから接続したことのない相手はリストされないということ??