Static Routes

Solaris 10 Update 3 and Later
From Solaris 10 Update 3 these is in built support for storing static routes. To add a route persistently add a '-p' switch when specifying the route, this will make the route active and persistent across reboots.

'route -p add -net 192.168.24.0/24 10.10.10.1'

This will be saved in /etc/inet/static_routes eg:

-net 192.168.128.0/22 192.168.136.1 -net 192.168.138.0/24 192.168.136.1 -net 172.31.68.0/24 192.168.149.253 -net 172.31.69.0/24 192.168.149.253
 * 1) File generated by route(1M) - do not edit.

To delete a route and remove it from static_routes do:

'route -p delete -net ....'

Solaris 10 Update 2 and Earlier
Solaris 10u2 and earlier don't have support for static routes.

Using the old S99static trick doesn't work as the rc2 scripts won't run if the system doesn't reach milestone/multiuser which can happen if a service (such as rpcbind) fails to start.

As such a new SMF service is required.

Put this in :-

 <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">



 

  















Then create the following (with modifications obv) at :-


 * 1) !/bin/sh


 * 1) RKstatic-routes


 * 1) To be called by the network/RKstatic-route SMF service

ACTION=${ACTION:-add}

setup_routes {

/usr/sbin/route $ACTION net 172.16.0.0 -netmask 255.255.0.0 10.25.0.216 /usr/sbin/route $ACTION net 172.18.0.0 -netmask 255.255.0.0 10.25.0.216 /usr/sbin/route $ACTION net 172.25.0.0 -netmask 255.255.0.0 10.25.0.216
 * 1) Route to NetBackup networks.

/usr/sbin/route $ACTION net 10.216.0.0 -netmask 255.255.0.0 10.25.0.216 /usr/sbin/route $ACTION net 10.218.0.0 -netmask 255.255.0.0 10.25.0.216 /usr/sbin/route $ACTION net 10.225.0.0 -netmask 255.255.0.0 10.25.0.216 }
 * 1) Route to SHMN networks.

case "$1" in   start)        echo "${ACTION}ing static routes"        setup_routes        ;;    stop) ACTION=delete echo "${ACTION}ing static routes" setup_routes ;;   *)        echo "Usage: $0 {start|stop}"        exit 1 esac

Then import the service:-

svccfg -v import /var/svc/manifest/network/RKstatic-routes.xml

Then you can enable and start the service with:-

svcadm enable network/RKstatic-routes

And remove the routes and disable the service with:-

svcadm disable network/RKstatic-routes

Enabling or disabling the routes with this method will persist across reboots.