Mac OS X: getting default route and ip addresses
Posted by jpluimers on 2015/11/30
On Mac OS X, bare route and ifconfig give way too much information to view the most important things at once.
So I used an alias for this:
route -n get default | grep 'gateway' && echo && ifconfig | grep '\: flags\|inet\|inet6'
Later I needed IPv6 support, so I changed it to:
netstat -nr | grep 'Internet\|Gateway\|default' && echo && ifconfig | grep '\: flags\|inet\|inet6'
So you get something like this:
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 192.168.178.1 UGSc 23 0 en4
default 192.168.71.1 UGScI 7 0 en0
Internet6:
Destination Gateway Flags Netif Expire
default fe80::3631:c4ff:fe47:13f1%en0 UGc en0
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet6 fe80::6203:8ff:fea2:4814%en0 prefixlen 64 scopeid 0x4
inet 192.168.71.40 netmask 0xffffff00 broadcast 192.168.71.255
inet6 2001:982:2345:1:6203:8ff:fea2:4814 prefixlen 64 autoconf
inet6 2001:982:2345:1:4011:119a:e527:e021 prefixlen 64 autoconf temporary
en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
en4: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet6 fe80::426c:8fff:fe44:95ea%en4 prefixlen 64 scopeid 0xb
inet6 fd00::426c:8fff:fe44:95ea prefixlen 64 detached autoconf
inet6 fd00::74a7:8f26:cd22:20b7 prefixlen 64 detached autoconf temporary
inet 192.168.178.22 netmask 0xffffff00 broadcast 192.168.178.255
–jeroen
via:






Leave a comment