Change Default Router Without Reboot


Tags:
                                  
View the routing table:
----------------------

netstat -rn

  Routing Table: IPv4
    Destination           Gateway           Flags  Ref   Use   Interface
  -------------------- -------------------- ----- ----- ------ ---------
  10.67.13.0           10.67.13.50           U        1     42  hme0
  10.67.3.0            10.67.3.65            U        1   9172  hme1
  224.0.0.0            10.67.13.50           U        1      0  hme0
  default              10.67.12.1            UG       1    148
  127.0.0.1            127.0.0.1             UH       2    783  lo0



Delete current default router:
-----------------------------

route delete default 10.67.12.1



Add new default router:
----------------------

route add default 10.67.13.1 1



View the routing table:
----------------------

netstat -rn

  Routing Table: IPv4
    Destination           Gateway           Flags  Ref   Use   Interface
  -------------------- -------------------- ----- ----- ------ ---------
  10.67.13.0           10.67.13.50           U        1     42  hme0
  10.67.3.0            10.67.3.65            U        1   9172  hme1
  224.0.0.0            10.67.13.50           U        1      0  hme0
  default              10.67.13.1            UG       1    148
  127.0.0.1            127.0.0.1             UH       2    783  lo0


if you're ssh'd in from afar, then combine the route delete and route add into one command.

route delete default 10.67.12.1 ; route add default 10.67.13.1

as separate commands you loose connectivity after the delete, so you can't enter the route add.

also to make the default route come up on the next reboot, change the address in:
/etc/defaultrouter

thanks!