Find gateway address and netmask?

Solution 1:

With ifconfig on OS X you can find netmask :

inet 192.168.1.2 netmask 0xffffff00 broadcast 192.168.1.255

netmask 0xffffff00 means 255.255.255.0

And for finding gateway address use arp -a or as geekosaur said use netstat -nr | grep '^default'.

Solution 2:

On most Unix-like systems, including OSX, that information comes from netstat -r (r for "route").