ip command in Mac OS X terminal

You can use brew to install iproute2mac. It's actually a Python wrapper that provides a very similar API that you'll likely find very familiar to the ip tool included with iproute2 on Linux.

Installation

$ brew install iproute2mac
==> Installing iproute2mac from brona/homebrew-iproute2mac
==> Downloading https://github.com/brona/iproute2mac/archive/v1.0.3.zip
######################################################################## 100.0%
🍺  /usr/local/Cellar/iproute2mac/1.0.3: 4 files,  24K, built in 2 seconds

Usage

Once installed you'll be given a command line tool that for all intent purposes mimics the ip command on Linux.

$ 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.

Examples

Show IP addresses on interface en0.

$ ip addr show en0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 54:46:12:fc:45:12
    inet6 fe80::3636:3bff:fecf:1294/64 scopeid 0x4
    inet 192.168.1.5/24 brd 192.168.1.255 en0

Show details about link en1.

$ ip link show en1
en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    options=60<TSO4,TSO6>
    ether 72:00:08:81:d2:10
    media: autoselect <full-duplex>
    status: inactive

References

  • brona/iproute2mac GitHub Page

Use the normal command for unix like systems: ifconfig.

(Linux also uses ifconfig, but some of the tools have newer versions. ip is one of these which one day will replace the old ifconfig.)


There is a simpler way without installing any tools:

$ which ifconfig
/sbin/ifconfig

$ ifconfig en0 | grep inet | grep -v inet6 | cut -d ' ' -f2
10.16.45.123