Operating System - HP-UX
1748204 Members
4380 Online
108759 Solutions
New Discussion

adding a persistant route in hpux

 
SOLVED
Go to solution
laiju.c.babu
Regular Advisor

adding a persistant route in hpux

Hi team,

 

I want to know how to add a persistent route in hpunix. I have added the below command for adding the route statically

 

route add host <Host Ip>  <gw ip>  1 source  <ip of lan2>  ==== > this one i have  executed for adding the route statically

 

/etc/rc.config.d/netconf i have added the below entry for making the above  route permanantly.

 

ROUTE_DESTINATION[3]="host Host ip"
ROUTE_MASK[3]="255.255.255.0"
ROUTE_GATEWAY[3]="gw ip"
ROUTE_COUNT[3]="1"
ROUTE_ARGS[3]=""

Could you please tell me the action which i did in netconf file is correct ?

 

Regards

 

 

P.S.This thread has been moved from HP-UX>System Administration to HP-UX > networking-HP Forums Moderator

 

Laiju.C.Babu
11 REPLIES 11
Matti_Kurkela
Honored Contributor

Re: adding a persistant route in hpux

Your netconf entry does not exactly match the "route add" command you used.

 

ROUTE_MASK is for network routes ("route add net ... netmask ...") only. If you are specifying a host route ("route add host ..."), then the ROUTE_MASK should be an empty string:

ROUTE_MASK[3]=""

 

In the "route add" command, the "source <ip of lan2>" part is optional - if you need it for special reasons, you should also add it to the ROUTE_ARGS line in netconf, i.e.:

ROUTE_ARGS[3]="source <ip of lan2>"

 

MK
laiju.c.babu
Regular Advisor

Re: adding a persistant route in hpux

Hi MK,

 

Thanks a lot for your reply. I have made the  changes you mentioned. As part of the scheduled reboot the server will get rebooted on the coming weekend.

 

If i am getting error on that time i wil  update you.

 

Regards.

 

Laiju.C.Babu
laiju.c.babu
Regular Advisor

Re: adding a persistant route in hpux

Hi MK,

 

After the reboot the  route is not get added. I can see the below error from rc.log

 

===================================================================

Configure LAN interfaces
Output from "/sbin/rc2.d/S340net start":
----------------------------
ERROR:  Failed to add route entry because its interface is not
        yet initialized.  May need to add this route entry with
        a route commad after the interface is up :
        source: unknown command
"/sbin/rc2.d/S340net start" FAILED
===================================================================

 

The entry which i gave  in /etc/rc.config.d/netconf is

 

ROUTE_DESTINATION[3]="host 10.144.8.4"
ROUTE_MASK[3]=""
ROUTE_GATEWAY[3]="10.144.17.1"
ROUTE_COUNT[3]="1"
ROUTE_ARGS[3]="source 10.144.17.152"

Could you please advise me on this

 

Regards

 

Laiju.C.Babu
Laurent Menase
Honored Contributor

Re: adding a persistant route in hpux

 

10.144.17.152 is not yet configured

 

are you using srp?

are you using ip strong es model set to 1?

 

 

 

 

laiju.c.babu
Regular Advisor

Re: adding a persistant route in hpux

Hi Laurent,

 

Sorry i didnt get your question.  Could you please explain a it ?

 

 

Regards

Laiju.C.Babu
Matti_Kurkela
Honored Contributor

Re: adding a persistant route in hpux

>        source: unknown command

 

Hmm... it does not seem to like the "source" option in the ROUTE_ARGS. Perhaps the /sbin/init.d/net script just cannot parse that option, although the route command supports it. (What is your HP-UX version, by the way?)

 

To fully understand the problem, I would need to check the /sbin/init.d/net script of the same HP-UX version (and ideally about the same patch level) as your system.

 

You could try reading the /sbin/init.d/net script: see if you can figure out how it builds up the arguments for the "route" command using the various ROUTE_ variables.

 

If you're trying to have a Serviceguard packaged application send its outgoing traffic through the package IP, then it might be better to add the "route" command to the Serviceguard package start-up scripts instead. (If you are using legacy-style packages, there is a place for customer-added package start/stop commands in the package control file; if you are using the new modular configuration style of the newer Serviceguard versions, you would write a script and call it from the package configuration file using the "external_script" keyword.

MK
laiju.c.babu
Regular Advisor

Re: adding a persistant route in hpux

Hi MK,

                I am using HP-Ux 11.23 . I am attaching  the file  /sbin/init.d/net Could you please have a look on this.

 

Regards

 

Laiju.C.Babu
Matti_Kurkela
Honored Contributor
Solution

Re: adding a persistant route in hpux

Okay. The part that interests us begins with this comment:

#
# Do route command for each configured route
#

 First it does some basic validation of the indexes of the ROUTE_ variables, then it starts a while loop that goes through each variable group in order.

 

Within the loop, the ROUTE_ variables of the currently processed group are copied to other variables with shorter names and no index:

   DEST=$(print ${ROUTE_DESTINATION[i]})
   GWAY=$(print ${ROUTE_GATEWAY[i]})
[...]
      ARGS=${ROUTE_ARGS[i]}
      MASK=$(print ${ROUTE_MASK[i]})

 

And finally, here's the part where the variables are assembled into a complete route command. There are four varieties, depending on whether the ROUTE_MASK is used or not, and whether ROUTE_ARGS is used or not.

     if [[ -z $MASK ]]; then
	 # No subnet mask
      	 if [[ -z $ARGS ]]; then 
	       # No arguments 
	       emsg=$(route add $DEST $GWAY $COUNT 2>&1)
         else 
	       # With arguments 
	       emsg=$(route $ARGS add $DEST $GWAY $COUNT 2>&1)
               fi 
      else
	 # Subnet mask has been entered.
      	 if [[ -z $ARGS ]]; then 
	       # No arguments 
	       emsg=$(route add $DEST netmask $MASK $GWAY $COUNT 2>&1)
      	 else 
	       # With arguments 
	       emsg=$(route $ARGS add $DEST netmask $MASK $GWAY $COUNT 2>&1)
	       fi 
	 fi

 And here is the problem: the content of the ARGS variable is placed at the very beginning of the list of arguments, instead of at the end.

 

The man page of the route command describes the syntax like this:

/usr/sbin/route [-f] [-n] [-p pmtu] add [net|host] destination [netmask mask] gateway [count] [source src]

 So, the ARGS variable (and thus the ROUTE_ARGS variables in /etc/rc.config.d/netconf) may only contain combinations of "-f", "-n" and "-p <pmtu value>".

The "source" option must be at the very end of the command, so ROUTE_ARGS is not the correct place for it after all. I'm sorry for giving you bad advice.

 

The "souce" option must go after the COUNT variable that comes from ROUTE_COUNT, but there is no variable that could be used.

 

If you absolutely must put the setting into /etc/rc.config.netconf and nowhere else, there might still be a way: looks like the COUNT variable gets special treatment only if the ROUTE_COUNT is left empty. If it is non-empty, anything that is put into ROUTE_COUNT seems to get passed to the route command line exactly as-is.

 

I would not recommend tricks like that in production systems. But if you must do it, then try settings like this in your /etc/rc.config.d/netconf file:

ROUTE_COUNT[3]="1 source 10.144.17.152"
ROUTE_ARGS[3]=""

The problem with a dirty hack like this is that SAM most likely will not understand it. If someone edits the system's route settings with SAM, the next time you boot the system you're likely to find that the source options have vanished. Or maybe SAM might show an error message.

MK
laiju.c.babu
Regular Advisor

Re: adding a persistant route in hpux

Hi MK,

 

Thanks a lot for your great help on this.

 

In production machine any way i had removed the vaule which we added for the variable ROUTE_ARGS. I am waiting for the reboot (which is on coming monday) to check  wether the route is getting added properly or not.

 

Mean while in  one of our testing server i will check the solution you provided  below and lets see what will happen.

 

I will keep you posted regarding the results.

 

Once again thanks a lot for your effort on this

 

Regards

 

Laiju.C.Babu