Solaris 10 : Add Static Routes to Solaris 10

For example, the following route commands with -p option will add or delete the persistent static routes.

# route -p add 192.168.1.0 129.148.192.248 1
# route -p delete 192.168.1.0 129.148.192.248

Note: -p option works only on solaris 10 with Patch ID: 122539-06 or Solaris 10 KU patch 118833-36 or above installed

To setup static routing on Solaris 10 systems, just create your own /etc/rc*.d/S*script containing the “route add” invocations desired or create a transient SMF service that adds routes at boot time as shown in the following two options.

Option 1:

Create a new startup script in /etc/rc2.d directory say S99Networkroutes and then in that file put “route add net” lines. Those routes will get added when system reboots.

# cat /etc/rc2.d/S99Networkroutes

#!/sbin/sh #
case “$1” in ‘start’)
# Put additional routes here:

# /usr/sbin/route add net 192.168.32.0 mygateway 1 -netmask 255.255.255.0
;;
‘stop’) exit 0 ;;
*) echo “Usage: $0 { start | stop }” exit 1 ;;
esac
Option 2:

– Create a script called /usr/bin/routeradd

# cat /usr/bin/routeradd

#!/bin/sh

# route add 192.168.1.0 129.148.192.248 1
– Create a .xml file

# cat /var/svc/manifest/network/routeadd.xml

 – Now import the xml data into the repository.

# svccfg -v import /var/svc/manifest/network/routeadd.xml
– Never try to disable it since this is not a service, it is a one shot script that will only run at boot time.

Ramdev

Ramdev

I have started unixadminschool.com ( aka gurkulindia.com) in 2009 as my own personal reference blog, and later sometime i have realized that my leanings might be helpful for other unixadmins if I manage my knowledge-base in more user friendly format. And the result is today's' unixadminschool.com. You can connect me at - https://www.linkedin.com/in/unixadminschool/

3 Responses

  1. kk says:

    hi
    I have an issue where I am unable to ping and reach an IP from one interface in solaris box. But I can traceroute the IP with different interface which have same subnet of IP which 1st interface has.
    ex:
    Problem:
    root@rinams02:/# traceroute 10.128.1.35
    traceroute: Warning: Multiple interfaces found; using 10.128.5.6 @ oce0:1
    traceroute to 10.128.1.35 (10.128.1.35), 30 hops max, 40 byte packets
    1 10.128.5.29 (10.128.5.29) 1.056 ms 0.927 ms 0.784 ms
    2 10.128.5.194 (10.128.5.194) 0.405 ms 0.419 ms 0.272 ms
    3 * * *
    4 ^C

    root@rinams02:/# traceroute -i oce0:6 10.128.1.35
    traceroute to 10.128.1.35 (10.128.1.35), 30 hops max, 40 byte packets
    1 10.128.5.29 (10.128.5.29) 1.288 ms 1.206 ms 1.568 ms
    2 10.128.5.194 (10.128.5.194) 0.382 ms 0.373 ms 0.385 ms
    3 10.128.1.28 (10.128.1.28) 0.679 ms 0.486 ms 0.427 ms
    4 10.128.1.35 (10.128.1.35) 0.385 ms 0.279 ms 0.323 ms

    root@rinams02:/# traceroute 10.128.1.36
    traceroute: Warning: Multiple interfaces found; using 10.128.5.6 @ oce0:1
    traceroute to 10.128.1.36 (10.128.1.36), 30 hops max, 40 byte packets
    1 10.128.5.29 (10.128.5.29) 1.067 ms 0.784 ms 0.751 ms
    2 10.128.5.194 (10.128.5.194) 0.363 ms 0.354 ms 0.282 ms
    3 * * *
    4 ^C

    root@rinams02:/# traceroute -i oce0:6 10.128.1.36
    traceroute to 10.128.1.36 (10.128.1.36), 30 hops max, 40 byte packets
    1 10.128.5.29 (10.128.5.29) 1.236 ms 0.833 ms 0.691 ms
    2 10.128.5.194 (10.128.5.194) 0.337 ms 0.273 ms 0.303 ms
    3 10.128.1.28 (10.128.1.28) 0.645 ms 0.503 ms 0.486 ms
    4 10.128.1.36 (10.128.1.36) 0.219 ms 0.184 ms 0.194 ms
    Similar behaviour is seen when doing ssh adding -b 10.128.5.7 (which is OSS VIP) to the node instead of just ssh user@node
    Thanks in advance for any hint on this.

    netstat -rn

    Routing Table: IPv4
    Destination Gateway Flags Ref Use Interface
    ——————– ——————– —– —– ———- ———
    default 10.128.5.1 UG 1 17169
    10.128.5.0 10.128.5.6 U 1 19141 oce0:1
    10.128.5.0 10.128.5.10 U 1 0 oce0:2
    10.128.5.0 10.128.5.9 U 1 0 oce0:3
    10.128.5.0 10.128.5.8 U 1 0 oce0:4
    10.128.5.0 10.128.5.11 U 1 0 oce0:5
    10.128.5.0 10.128.5.7 U 1 0 oce0:6
    10.128.5.0 10.128.5.6 U 1 0 oce0
    10.128.5.0 10.128.5.6 U 1 1 oce9
    10.128.5.5 200.200.200.15 UGH 1 1
    192.168.100.0 192.168.100.35 U 1 1350595 oce2:1
    192.168.100.0 192.168.100.35 U 1 0 oce2
    192.168.100.0 192.168.100.35 U 1 1350390 oce11
    192.168.128.0 192.168.128.6 U 1 24 oce3
    192.168.128.0 192.168.128.5 U 1 0 oce3:1
    192.168.128.0 192.168.128.4 U 1 0 oce3:2
    200.200.200.0 200.200.200.35 U 1 1 oce10
    224.0.0.0 10.128.5.6 U 1 0 oce0:1
    127.0.0.1 127.0.0.1 UH 122 2553507 lo0

    ifconfig -a
    lo0: flags=2001000849 mtu 8232 index 1
    inet 127.0.0.1 netmask ff000000
    oce0: flags=9040843 mtu 1500 index 2
    inet 10.128.5.14 netmask ffffffe0 broadcast 10.128.5.31
    groupname pub_mnic
    ether 78:ac:c0:f7:47:4
    oce0:1: flags=1000843 mtu 1500 index 2
    inet 10.128.5.6 netmask ffffffe0 broadcast 10.128.5.31
    oce0:2: flags=1000843 mtu 1500 index 2
    inet 10.128.5.10 netmask ffffffe0 broadcast 10.128.5.31
    oce0:3: flags=1000843 mtu 1500 index 2
    inet 10.128.5.9 netmask ffffffe0 broadcast 10.128.5.31
    oce0:4: flags=1000843 mtu 1500 index 2
    inet 10.128.5.8 netmask ffffffe0 broadcast 10.128.5.31
    oce0:5: flags=1000843 mtu 1500 index 2
    inet 10.128.5.11 netmask ffffffe0 broadcast 10.128.5.31
    oce0:6: flags=1000843 mtu 1500 index 2
    inet 10.128.5.7 netmask ffffffe0 broadcast 10.128.5.31
    oce2: flags=9040843 mtu 1500 index 5
    inet 192.168.100.36 netmask ffffff80 broadcast 192.168.100.127
    groupname stor_mnic
    ether 78:ac:c0:f7:47:5
    oce2:1: flags=1000843 mtu 1500 index 5
    inet 192.168.100.35 netmask ffffff80 broadcast 192.168.100.127
    oce3: flags=1000843 mtu 1500 index 6
    inet 192.168.128.6 netmask ffffffc0 broadcast 192.168.128.63
    ether 78:ac:c0:f7:47:9
    oce3:1: flags=1000843 mtu 1500 index 6
    inet 192.168.128.5 netmask ffffffc0 broadcast 192.168.128.63
    oce3:2: flags=1000843 mtu 1500 index 6
    inet 192.168.128.4 netmask ffffffc0 broadcast 192.168.128.63
    oce9: flags=9040843 mtu 1500 index 7
    inet 10.128.5.15 netmask ffffffe0 broadcast 10.128.5.31
    groupname pub_mnic
    ether 78:ac:c0:f7:47:10
    oce10: flags=1000843 mtu 1500 index 3
    inet 200.200.200.35 netmask ffffff00 broadcast 200.200.200.255
    ether 78:ac:c0:f7:47:d
    oce11: flags=9040843 mtu 1500 index 4
    inet 192.168.100.37 netmask ffffff80 broadcast 192.168.100.127
    groupname stor_mnic

    root@rinams02:/# cat /etc/netmasks
    #
    # The netmasks file associates Internet Protocol (IP) address
    # masks with IP network numbers.
    #
    # network-number netmask
    #
    # 128.32.0.0 255.255.255.0
    #
    10.128.5.0 255.255.255.224
    192.168.100.0 255.255.255.128
    200.200.200.0 255.255.255.0
    192.168.128.0 255.255.255.192

    root@rinams02:/# cat /etc/hostname*
    10.128.5.14 netmask + broadcast + deprecated -failover up
    addif 10.128.5.6 netmask + broadcast + up
    200.200.200.35
    192.168.100.37 netmask + broadcast + deprecated -failover up
    192.168.100.36 netmask + broadcast + deprecated -failover up
    addif 192.168.100.35 netmask + broadcast + up
    rinams02-bkp
    10.128.5.15 netmask + broadcast + deprecated -failover up
    root@rinams02:/# cat /etc/hostname*
    hostname.oce0 hostname.oce11 hostname.oce3
    hostname.oce10 hostname.oce2 hostname.oce9
    root@rinams02:/# cat /etc/hostname.oce0
    10.128.5.14 netmask + broadcast + deprecated -failover up
    addif 10.128.5.6 netmask + broadcast + up

    eshlkhn@rinams02> ping 10.128.20.2
    10.128.20.2 is alive
    eshlkhn@rinams02> ping 10.128.3.1
    10.128.3.1 is alive
    eshlkhn@rinams02> ping 10.128.3.133
    10.128.3.133 is alive
    eshlkhn@rinams02> ping 10.128.3.132
    10.128.3.132 is alive
    eshlkhn@rinams02> ping 10.128.3.11
    10.128.3.11 is alive
    eshlkhn@rinams02> traceroute 10.128.3.11
    traceroute: Warning: Multiple interfaces found; using 10.128.5.6 @ oce0:1
    traceroute to 10.128.3.11 (10.128.3.11), 30 hops max, 40 byte packets
    1 10.128.5.29 (10.128.5.29) 1.085 ms 0.944 ms 0.617 ms
    2 10.128.5.194 (10.128.5.194) 0.264 ms 0.336 ms 0.245 ms
    3 10.128.3.11 (10.128.3.11) 1.278 ms 2.171 ms 2.125 ms

    • Ramdev Ramdev says:

      Hi KK, Jsut few questions

      >> is that oce0:1 having problem with only 10.128.1.x subnet destination IPs?
      >> Do you able to ping/traceroute from 10.128.1.35 ( outside IP) to 10.128.5.6 (oce0:1) ?
      >> are there any ipfilters set on this machine?

  1. September 17, 2015

    […] Read – Add Static Routes to Solaris 10 […]

What is in your mind, about this post ? Leave a Reply

Close
  Our next learning article is ready, subscribe it in your email

What is your Learning Goal for Next Six Months ? Talk to us