Setting default route on Solaris (updated)

In this article we describe the configuration command to add a default route temporally and permanently to Solaris system.

The Default Gateway or the Default Router is the IP address (IPv4) to which all the traffic to any target destination(s) which does not have a route in the Routing Table of the server will be forwarded.

Setting the default route on Solaris is easy. If you are trying to just set the route temporarily you can use the route command:

Solaris 2.6, 7, 8 & 9

  • You can add default router temporarily by following command:
    # route add default 192.168.1.254
  • You can add default router permanently by following command:
    # echo 192.168.1.254 > /etc/defaultrouter

    It will create /etc/defaultrouter file if not already available. Next time you restart you system 192.168.1.254 will be automatically added to default router.

Solaris 10 & 11

  • You can add default router temporarily using the following command:
    # route add default 192.168.1.254
  • We can then add a persistent default route using the following command:
    # route -p add default 192.168.1.254
    add net default: gateway 192.168.1.254
    add persistent net default: gateway 192.168.1.254

View existing IP routing table

# netstat -rn

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface 
-------------------- -------------------- ----- ----- ---------- ---------
192.168.1.0          192.168.1.10         U         1        195 hme0
224.0.0.0            192.168.1.10         U         1          0 hme0
default              192.168.1.254        UG        1        325
127.0.0.1            127.0.0.1            UH        5         92 lo0