SysAdmin's Journey

Setting Persistent Static Routes on Solaris 10

It used to be that in order to add persistent static routes in Solaris, you had to whip up your own init script that manually ran ‘route add’. Starting back in Solaris 10 11/06, Sun finally gave us a better way to do it. From the route(1M) man page:


         Make changes to  the  network  route  tables  persistent
         across  system restarts. The operation is applied to the
         network routing tables first and, if successful, is then
         applied  to  the  list  of  saved  routes used at system
         startup. In determining whether an  operation  was  suc-
         cessful, a failure to add a route that already exists or
         to delete a route that is not in the  routing  table  is
         ignored. Particular care should be taken when using host
         or network names in persistent routes, as  network-based
         name  resolution  services are not available at the time
         routes are added at startup.

So, all you need to do to add a static route for to be accessed via gateway on each boot is this:

/usr/sbin/route -p add

Currently, these routes are stored in /etc/inet/static_routes, but Sun doesn’t guarantee it will stay there. I’m not sure I like being forced to use a command when I could just edit a config file, but it’s a definite improvement!