How do I change the gateway of a specific connection using the Mac terminal? My goal is to be able to change all of the following for a specific device: IP address, netmask, and gateway. So far, I've gathered that I should be able to use ifconfig con0 10.8.0.14 netmask 255.255.255.252, but when I try to do ifconfig con0 gateway 10.8.0.1, it gets pretty upset and tells me that gateway is a bad argument. 

Thoughts?
The command you're looking for is route.

Check what your current gateway is

To check your current gateway, run the command:

route -n get -ifscope en0 default


This instructs route to return the path it would take using en0 to reach www.google.com.


The -n argument turns off domain name resolution in the output (else gateway in the sample output below would be the name of my gateway).
The -ifscope argument limits the query to using en0.  Without it, to OS will select which interface to use.
default tells route that you want to see the default gateway.  You can put a URL here instead if you suspect your OS is choosing something other than the default gateway to access a host.


The output will be something along the lines of:

   route to: default
destination: default
       mask: default
    gateway: 192.168.1.1
  interface: en0
      flags: &lt;UP,GATEWAY,DONE,STATIC,PRCLONING,IFSCOPE&gt;
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0      1500         0 


Delete the current gateway

To delete the current gateway from en0, run:

sudo route delete default -ifscope en0


This will delete the default gateway from en0 while leaving any other defined routes intact.  

Add the new gateway

To add the new gateway to en0, run:

sudo route add default 192.168.1.1 -ifscope en0


Replace 192.168.1.1 with the IP address of the actual gateway.

For way more gory details, check out the man page for route.