らっちゃいブログ

日々の学びと気づきを発信するブログ

Macにipコマンドをインストールしたのでメモ

スポンサーリンク

普段 Ubuntu マシンをメインに据えて Mac をサブマシンとして開発しているわけですが、Mac に ip コマンドがないのが不便だったのでインストールしてみました。

インストール

今回は homebrew でインストールしました。

brew tap brona/iproute2mac
brew install iproute2mac

確認してみる。

$ 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 コマンドで IP アドレスを確認してみます。

$ ip add
$ ip a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        inet6 ::1/128
        inet 127.0.0.1/8 lo0
        inet6 fe80::1/64 scopeid 0x1
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ether xx:xx:xx:xx:xx:xx
        inet6 xxxx::xxxx:xxxx:xxxx:xxxx/64 scopeid 0x4
        inet xx.xx.xx.xx/24 brd xx.xx.xx.255 en0

無事動いてますね。これで ubuntumac でコマンドが違う問題が解決されました。ばんざい。