Mac OS X 터미널의 ip 명령 나는 ip

나는 ip link리눅스 에서 명령 을 사용합니다 . 이제 Mac OS X에서 원하지만 Mac OS X 터미널에는이 없습니다 ip. 대신 무엇을 사용해야합니까?



답변

brew설치 하는 데 사용할 수 있습니다 iproute2mac. 실제로는 Linux에 ip포함 된 도구에 매우 익숙한 API를 제공하는 Python 래퍼입니다 iproute2.

설치

$ 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

용법

일단 설치되면 모든 목적을 위해 ipLinux 에서 명령을 모방하는 명령 행 도구가 제공됩니다 .

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

인터페이스 en0에 IP 주소를 표시하십시오.

$ 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

링크 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

참고 문헌


답변

유닉스 계열 시스템의 경우 일반 명령을 사용하십시오 : ifconfig.

(리눅스는 ifconfig도 사용하지만 일부 도구는 최신 버전을 가지고 있습니다. ip그 중 하나는 이전 ifconfig를 대체 할 도구 중 하나입니다.)


답변

도구를 설치하지 않고 더 간단한 방법이 있습니다.

$ which ifconfig
/sbin/ifconfig

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

답변

Mac에는 ip 명령이 없습니다. 양조장에서 얻거나 사용하십시오.

ifconfig en0| grep "inet[ ]" | awk '{print $2}'

~/.bash_profile다음과 같이 별명을 작성할 수 있습니다 .

alias ip-addr="ifconfig en0| grep \"inet[ ]\" | awk '{print \$2}'"