Operating System - HP-UX
1844985 Members
2002 Online
110233 Solutions
New Discussion

how to make a permanent route

 
cedrichiu
Frequent Advisor

how to make a permanent route

hi,

does anyone know how to make permanent route and even after server reboot, the route will still be existed in routing table?

Thanks
16 REPLIES 16
Matti_Kurkela
Honored Contributor

Re: how to make a permanent route

Sure. Edit /etc/rc.config.d/netconf and add your permanent route in there.

For example, if you want this route made permanent:

route add net 10.20.30.0 netmask 255.255.255.0 10.2.2.2 1

... you would add lines like this to the netconf file:

ROUTE_DESTINATION[x]="net 10.20.30.0"
ROUTE_MASK[x]="255.255.255.0"
ROUTE_GATEWAY[x]="10.2.2.2"
ROUTE_COUNT[x]=1

Replace "x" with the first unused index number for a set of route entries. Usually the default gateway is defined with index 0.
If you have no other permanent routes defined yet, "x" would be 1 in your new route configuration lines.

MK
MK
cedrichiu
Frequent Advisor

Re: how to make a permanent route

hi,

Thanks. What happen if the destination is a server, and I don't really quite sure the gateway. Could your given guide works well ?

Appreciate that.
Steven E. Protter
Exalted Contributor

Re: how to make a permanent route

Shalom,

I change the route information in /etc/rc.config.d/netconf

Note: Backup copies should not reside in /etc/rc.config.d

You can set default routes and secondary routes.

netstat -rn
# To see the results.

Be careful about typoes in that file, which has fairly good internal documentation.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Matti_Kurkela
Honored Contributor

Re: how to make a permanent route

The default route/gateway specification looks like this (replace 11.22.33.44 with your default gateway):

ROUTE_DESTINATION[0]="default"
ROUTE_MASK[0]=""
ROUTE_GATEWAY[0]="11.22.33.44"
ROUTE_COUNT[0]=1

The index number [in brackets] for the default gateway is typically 0, because this entry is usually created by the OS installation procedure. All other permanent routes are created by the sysadmin.

A single-host route would be specified like this:

ROUTE_DESTINATION[x]="host 10.11.12.13"
ROUTE_MASK[x]=""
ROUTE_GATEWAY[x]="22.33.44.55"
ROUTE_COUNT[x]=1

MK
MK
cedrichiu
Frequent Advisor

Re: how to make a permanent route

hi MK,

Does any network services need to restarted after modification ?

Is that correct ?
> /sbin/init.d/net stop and start

Regards
Matti_Kurkela
Honored Contributor

Re: how to make a permanent route

Any changes to /etc/rc.config.d/netconf take effect only when "/sbin/init.d/net start" is executed, which happens automatically at system reboot.

If you are not familiar with editing the /etc/rc.config.d/netconf file, running "/sbin/init.d/net stop; /sbin/init.d/net start" or rebooting the system is recommended to confirm that your syntax is correct.


But running /sbin/init.d/net may cause a total loss of all network connections for a few seconds: it does more actions than is strictly necessary for adding a route. If you need to add a new route without any kind of service interruption, you *can* add the route using the "route" command without any service interruption, and edit /etc/rc.config.d/netconf to cause the new route be auto-added at system startup.

Of course, if you do this, you should document the change so that you and your fellow sysadmins will know where to start troubleshooting if the system does not successfully start up networking after the next scheduled maintenance break...

NOTE: if you want to keep a backup version of the /etc/rc.config.d/netconf file, do not leave the backup in /etc/rc.config.d directory: move it somewhere else.

MK
MK
cedrichiu
Frequent Advisor

Re: how to make a permanent route

hi,

can you advise why it still encounter error in adding route to 10.200.64.132 via lan2? In fact lan2 is pingable


psa1a:/root# /sbin/init.d/net stop
psa1a:/root# /sbin/init.d/net 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 :
add host 10.200.64.132: gateway 172.19.149.140: Network is unreachable
psa1a:/root#
psa1a:/root# ping 172.19.149.140
PING 172.19.149.140: 64 byte packets
64 bytes from 172.19.149.140: icmp_seq=0. time=0. ms
64 bytes from 172.19.149.140: icmp_seq=1. time=0. ms

----172.19.149.140 PING Statistics----
2 packets transmitted, 2 packets received, 0% packet loss
round-trip (ms) min/avg/max = 0/0/0
psa1a:/root# ifconfig lan2
lan2: flags=1843
inet 172.19.149.140 netmask ffffff80 broadcast 172.19.149.255
Johnson Punniyalingam
Honored Contributor

Re: how to make a permanent route

>>psa1a:/root# /sbin/init.d/net stop
psa1a:/root# /sbin/init.d/net start
ERROR: Failed to add route entry because its interface is not
yet initialized. May need to add this route entry with<<<

why did you do this <> already explained to you , you just adding the route

can post below

ioscan -fnC lan
netstat -in
netstat -rn
Problems are common to all, but attitude makes the difference
cedrichiu
Frequent Advisor

Re: how to make a permanent route

psa1a:/root# ioscan -fnC lan
Class I H/W Path Driver S/W State H/W Type Description
========================================================================
lan 0 0/1/2/0 igelan CLAIMED INTERFACE HP PCI 1000Base-T Core
lan 1 0/3/1/0/6/0 iether CLAIMED INTERFACE HP AD193-60001 PCI/PCI-X 1000Base-T 4Gb FC/1000B-T Combo Adapter
lan 2 0/4/1/0/6/0 iether CLAIMED INTERFACE HP AD193-60001 PCI/PCI-X 1000Base-T 4Gb FC/1000B-T Combo Adapter
lan 3 0/6/1/0 iether CLAIMED INTERFACE HP AD331-60001 PCI/PCI-X 1000Base-T Adapter



psa1a:/root# netstat -in
Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll
lan0:1 1500 172.19.149.96 172.19.149.105 6230860 0 5799123 0 0
lan3* 1500 none none 0 0 0 0 0
lan2 1500 172.19.149.128 172.19.149.140 89637 0 153384 0 0
lan1* 1500 none none 0 0 0 0 2
lan0 1500 172.19.149.96 172.19.149.103 1608065 0 3613124 0 0
lo0 4136 127.0.0.0 127.0.0.1 730889 0 730889 0 0
lan2:1 1500 172.19.149.128 172.19.149.142 0 0 28 0 0




psa1a:/root# netstat -rn
Routing tables
Destination Gateway Flags Refs Interface Pmtu
127.0.0.1 127.0.0.1 UH 0 lo0 4136
172.19.149.142 172.19.149.142 UH 0 lan2:1 4136
172.19.149.140 172.19.149.140 UH 0 lan2 4136
172.19.149.103 172.19.149.103 UH 0 lan0 4136
172.19.149.105 172.19.149.105 UH 0 lan0:1 4136
10.200.64.132 172.19.149.105 UH 0 lan0:1 0
172.19.149.96 172.19.149.103 U 3 lan0 1500
172.19.149.96 172.19.149.105 U 3 lan0:1 1500
172.19.149.128 172.19.149.140 U 3 lan2 1500
172.19.149.128 172.19.149.142 U 3 lan2:1 1500
10.200.64.132 172.19.149.105 UH 0 lan0:1 1500
10.200.64.132 172.19.149.103 UH 0 lan0 1500
10.200.64.132 172.19.149.140 UH 0 lan2 1500
127.0.0.0 127.0.0.1 U 0 lo0 0
default 172.19.149.126 UG 0 lan0 0
Johnson Punniyalingam
Honored Contributor

Re: how to make a permanent route

can you post your "/etc/rc.config.d/netconf


can we try like

route add net netmask 1

Problems are common to all, but attitude makes the difference
cedrichiu
Frequent Advisor

Re: how to make a permanent route

hi,

This what had added into netconf prior to this

ROUTE_DESTINATION[0]=default
ROUTE_GATEWAY[0]=172.19.149.126
ROUTE_COUNT[0]=1

IP_ADDRESS[2]=172.19.149.140
SUBNET_MASK[2]=255.255.255.128
INTERFACE_NAME[2]=lan2
DHCP_ENABLE[2]=0
BROADCAST_ADDRESS[2]=172.19.149.255
INTERFACE_STATE[2]=up

ROUTE_DESTINATION[1]="10.200.64.132"
ROUTE_GATEWAY[1]="172.19.149.140"
ROUTE__MASK[1]=255.255.255.255
ROUTE_COUNT[1]=1

ROUTE_DESTINATION[2]="10.200.64.132"
ROUTE_GATEWAY[2]="172.19.149.103"
ROUTE_MASK[2]=255.255.255.255
ROUTE_COUNT[2]=1

ROUTE_DESTINATION[3]="10.200.64.132"
ROUTE_GATEWAY[3]="172.19.149.105"
ROUTE_MASK[3]=255.255.255.255
ROUTE_COUNT[3]=1

Any reason I can't successfully add to the routing table ?

Johnson Punniyalingam
Honored Contributor

Re: how to make a permanent route

can I know your ip address which you want add the route table,

I have some idea after seeing you netconf file

please provide so that i shall give command

so we shall try with "static" than we shall add the entries under the netconf file for permant
Problems are common to all, but attitude makes the difference
cedrichiu
Frequent Advisor

Re: how to make a permanent route

hi,

10.200.64.132 is IP which I need to add route for permanent route to netconf.

By manually, but still can't reach the IP

route add net 10.200.64.132 netmask 255.255.255.255 172.19.149.140




Johnson Punniyalingam
Honored Contributor

Re: how to make a permanent route


command shoudl as below

route add net 10.200.64.132 255.255.255.255 172.19.149.140 1


But Below shows you have already add route as per above posted from yours
=========================================================================

# netstat -rn
Routing tables

Destination Gateway Flags Refs Interface Pmtu

10.200.64.132 172.19.149.140 UH 0 lan2 1500

127.0.0.0 127.0.0.1 U 0 lo0 0

default 172.19.149.126 UG 0 lan0 0
Problems are common to all, but attitude makes the difference
cedrichiu
Frequent Advisor

Re: how to make a permanent route

route add net 10.200.64.132 255.255.255.255 172.19.149.140 1 --> say "add net 10.200.64.132: gateway 255.255.255.255: Network is unreachable"

AS because, I was using route add net 10.200.64.132 netmask 255.255.255.255 172.19.149.140"

How difference between these 2 ?

Johnson Punniyalingam
Honored Contributor

Re: how to make a permanent route

>>How difference between these 2 ?<<

difference its counts 1
Problems are common to all, but attitude makes the difference