Change the default route in Solaris

Contributor Icon Contributed by qmchenry Date Icon July 11, 2003  
Tag Icon Tagged: Solaris networking


Step 1: edit /etc/defaultrouter

Using the editor of your choice, edit the file /etc/defaultrouter — the only line in the file should be the default route of the system, for example: 192.168.1.1. This change will not take effect until the system is rebooted.

Step 2: Delete the current default route

To make the route change take effect immediately, you must first delete the default route. If the current default route is 192.168.254.1, then the command would be:

route delete default 192.168.254.1

Step 3: Assign the current default route

To implement the new default route without rebooting the system, use the following command substituting your default route for 192.168.1.1:

route add default 192.168.1.1

| Next recipe |
 
  • Anonymous
    If you are on a remote network from this sun box, this command series will not work reliably, since you will have just deleted the route telling solaris how to get back to you. Of couse, if you're on the console this doesn't matter.

    If you must do this without a reboot, wrap the 2 commands above into a one-off script, and execute it that way.
  • koen
    You might want to try this, after updating /etc/defaultrouter:
    route change default `cat /etc/defaultrouter `

    A lot less wordy and no need to write a script in order to ensure your connectivity.

    Koen
  • tanvirscsa
    Can I add more then one default router in solaris
  • Adrien HEBRARD
    Faster on Solaris 10:

    route change default 192.168.1.1

    This should be run for permanent modification:

    route -p change default 192.168.1.1
  • Thanks Adrien, your help is appreciated
  • Rusman
    Thanks for the tip!
  • DT
    If you want to make the route persistent, use this:
    route -p add default 192.168.1.1
blog comments powered by Disqus