I need to retrieve the default gateway on a Mac machine. I know that in Linux route -n will give an output from which I can easily retrieve this information. However this is not working in Mac OSX(Snow Leopard).
I also tried netstat -nr | grep 'default', but I was hoping for a cleaner output like that produced by route -n in Linux/Unix. netstat -nr lists all the interfaces and the default gateway for them.
Any kind of suggestion or a hint in the right direction will be appreciated.
You can try with:
It is not the same as GNU/Linux’s
route -n(or evenip route show) but is useful for checking the default route information.Also, you can check the route that packages will take to a particular host. E.g.
The output would be similar to:
IMHO

netstat -nris what you need. Even MacOSX’s Network utility app(*) uses the output of netstat to show routing information.(*) You can start Network utility with
open /Applications/Utilities/Network\ Utility.app