This simple command will print the routing table from a Mac computer.
deusexmachina:~ jason$ netstat -nr Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 192.168.1.1 UGSc 69 0 en0 127 127.0.0.1 UCS 0 0 lo0 127.0.0.1 127.0.0.1 UH 2 120 lo0 169.254 link#4 UCS 0 0 en0 192.168.1 link#4 UCS 0 0 en0 192.168.1.1/32 link#4 UCS 1 0 en0 192.168.1.1 c8:14:51:5f:a9:47 UHLWIir 72 121 en0 1192 192.168.1.4/32 link#4 UCS 0 0 en0 224.0.0/4 link#4 UmCS 1 0 en0 224.0.0.251 1:0:5e:0:0:fb UHmLWI 0 0 en0 255.255.255.255/32 link#4 UCS 0 0 en0 Internet6: Destination Gateway Flags Netif Expire default fe80::%utun0 UGcI utun0 ::1 ::1 UHL lo0 fdc8:1451:5fa9:4700:841:fe02:71d3:42bc e0:ac:cb:9c:18:a2 UHL lo0 fdc8:1451:5fa9:4700:5406:1d7:cd34:b83f e0:ac:cb:9c:18:a2 UHL lo0 fe80::%lo0/64 fe80::1%lo0 UcI lo0 fe80::1%lo0 link#1 UHLI lo0 fe80::%en0/64 link#4 UCI en0 fe80::1%en0 c8:14:51:5f:a9:47 UHLWIi en0 fe80::cad:d55e:43b7:7711%en0 e0:ac:cb:9c:18:a2 UHLI lo0 fe80::%awdl0/64 link#8 UCI awdl0 fe80::b896:d7ff:fe26:2fd3%awdl0 ba:96:d7:26:2f:d3 UHLI lo0 fe80::%utun0/64 fe80::36bc:422f:31d4:c493%utun0 UcI utun0 fe80::36bc:422f:31d4:c493%utun0 link#9 UHLI lo0 ff01::%lo0/32 ::1 UmCI lo0 ff01::%en0/32 link#4 UmCI en0 ff01::%awdl0/32 link#8 UmCI awdl0 ff01::%utun0/32 fe80::36bc:422f:31d4:c493%utun0 UmCI utun0 ff02::%lo0/32 ::1 UmCI lo0 ff02::%en0/32 link#4 UmCI en0 ff02::%awdl0/32 link#8 UmCI awdl0 ff02::%utun0/32 fe80::36bc:422f:31d4:c493%utun0 UmCI utun0 |
This command may be shortened like this to only show the ipv4 tables.
deusexmachina:~ jason$ netstat -nr -f inet Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 192.168.1.1 UGSc 77 0 en0 127 127.0.0.1 UCS 0 0 lo0 127.0.0.1 127.0.0.1 UH 2 138 lo0 169.254 link#4 UCS 0 0 en0 192.168.1 link#4 UCS 1 0 en0 192.168.1.1/32 link#4 UCS 1 0 en0 192.168.1.1 c8:14:51:5f:a9:47 UHLWIir 80 144 en0 1171 192.168.1.4/32 link#4 UCS 0 0 en0 192.168.1.255 ff:ff:ff:ff:ff:ff UHLWbI 0 1 en0 224.0.0/4 link#4 UmCS 1 0 en0 224.0.0.251 1:0:5e:0:0:fb UHmLWI 0 0 en0 255.255.255.255/32 link#4 UCS 0 0 en0 |
This prints the Mac OSX routing table properly. On a Linux machine, a user would use ip route
. But this works differently on a Mac. This is how to do it though. I guess a newer mac might have the ip command. That is superseding the route command on Linux machines. The route(8) manual page suggests to use ip instead. So, it is the better choice to learn.