You can use
yudeMacBook-Air:tinc brite$ cd /usr/local/Cellar/iproute2mac/1.2.1
https://www.zhihu.com/question/22761563
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.2.1: 6 files, 24K, built in 2 seconds
安装后,其可执行文件为ip:
yudeMacBook-Air:tinc brite$ cd /usr/local/Cellar/iproute2mac/1.2.1
yudeMacBook-Air:1.2.1 brite$ ls
AUTHORS LICENSE bin
INSTALL_RECEIPT.json README.md
yudeMacBook-Air:1.2.1 brite$ ls bin
ip
yudeMacBook-Air:1.2.1 brite$ which ip
/usr/local/bin/ip
yudeMacBook-Air:1.2.1 brite$
Usage
Once installed you'll be given a command line tool that for all intent purposes mimics theip
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
from https://superuser.com/questions/687310/ip-command-in-mac-os-x-terminalhttps://www.zhihu.com/question/22761563
No comments:
Post a Comment