"ip route get 8.8.8.8" equivalent in Mac?
In Linux, I use ip route get 8.8.8.8
to determine the route and interface to connect to IP 8.8.8.8.
Since iproute2 is unavailable on Mac, what should I use instead?
Solution 1:
You can simply use the route(8)
command
$ route get 8.8.8.8
route to: dns.google
destination: default
mask: default
gateway: 192.168.0.1
interface: en0
flags: <UP,GATEWAY,DONE,STATIC,PRCLONING>
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1500 0
The ip
tool is not supported on MacOS because it's a very Linux-specific implementation (Netlink). The Mac version of route
uses another interface (see man 4 route
).