×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles
    Revision as of 09:04, 3 June 2008 by imported>DrOwl (Static Routes (Solaris 10) moved to Static Routes: Will add routes for non solaris ten)

    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:

    # File generated by route(1M) - do not edit.
    -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
    

    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 /var/svc/manifest/network/RKstatic-routes.xml:-

    <?xml version="1.0"?>
    <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
    <!--
            Static Route SMF Manefest
    
            To be replaced by official Sun mechanism in next solaris release
    
    -->
    <service_bundle type='manifest' name='RKstatic-routes'>
    
    <service
      name='network/RKstatic-routes'
      type='service'
    
      version='1'>
        <create_default_instance enabled='true' />
    
        <single_instance/>
        <dependency name='network'
            grouping='require_any'
            restart_on='error'
            type='service'>
                <service_fmri value='svc:/network/service' />
        </dependency>
    
    
      <exec_method
        type='method'
        name='start'
    
        exec='/lib/svc/method/RKstatic-routes start'
    
        timeout_seconds='60' />
    
      <exec_method
    
        type='method'
        name='stop'
        exec='/lib/svc/method/RKstatic-routes stop'
    
        timeout_seconds='60' />
    
      <property_group name='startd' type='framework'>
    
        <propval name='duration' type='astring' value='transient' />
    
      </property_group>
    
      <stability value='Unstable' />
    
    </service>
    </service_bundle>
    

    Then create the following (with modifications obv) at /lib/svc/method/RKstatic-routes:-

    #!/bin/sh
    
    # RKstatic-routes
    
    # To be called by the network/RKstatic-route SMF service
    
    ACTION=${ACTION:-add}
    
    setup_routes () {
    
    
    #Route to NetBackup networks.
    /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
    
    # Route to SHMN 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
    }
    
    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.


    Solaris < 10 (r3)

    Adding static routes required soem fiddling:


    I genral people just made a rc script to add the routes:

    RC script to add routes

    this tpyical script is not quite right... ($type $route and $gateway and only two values in the routes.conf)

    ln -s /etc/rc2.d/S95staticRoutes /etc/init.d/staticRoutes.sh
    cat staticRoutes.sh
    #!/bin/sh
    
    case "$1" in
    
            start)
                    test -f /etc/routes.conf || exit 0
                    while read type route gateway
                    do
                            /usr/sbin/route add $type $route $gateway
                    done < /etc/routes.conf
                    ;;
    
            stop)
                    test -f /etc/routes.conf || exit 0
                    while read type route gateway
                    do
                            /usr/sbin/route delete $type $route $gateway
                    done < /etc/routes.conf
                    ;;
    
            *)
                    echo "Usage: /etc/init.d/routes { start | stop }"
                    ;;
    
    esac
    

    routes.conf

    #cat /etc/routes.conf
    172.19.42.0/24 172.19.41.4
    172.19.43.0/24 172.19.41.4
    



    But to be clean on Solaris 8, 9 and 10 you can add your static routes at /etc/gateways like this:

    net 100.100.100.0 gateway 192.1.243.1 metric 1
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.