1826107 Members
5173 Online
109690 Solutions
New Discussion

Re: standby route

 
John Waller
Esteemed Contributor

standby route

I don't know if I'm having a bad day or if its just because Christmas is comming but I'm having a routing problem. We have just installed a second router to act as a live standby and I am tring to configure my hpux-11.00 system to use this.

I use the commands:

route add net 172.19.5.0 netmask 255.255.255.0 router1 1
route add net 172.19.5.0 netmask 255.255.255.0 router2 2
trying to set metrics of 1 and 2 for primary and standby route.

A netstat -r command shows the following

172.19.5.0 router2 UG 0 0 lan1 1500
172.19.5.0 router1 UG 0 0 lan1 1500

Problem is router2 though it has a metric of 2 appears first and if this is not available I can not see the 172.19.5 network. If I delete this second route with route delete then I can contact the 172.19.5 network.

I know its a silly mistake, but what am I doing wrong??

5 REPLIES 5
Jeff Schussele
Honored Contributor

Re: standby route

Hi John,

That final value in a route command is a hop count - not a metric or index value. It defines how many devices the packet must traverse to reach that device. If it's on the same subnet as the host - the count would always be 1.
Also the route stack is just that. The last statement added to it is the first used & listed.
So it's probably the mistaken hop count that messes up the route & when you delete it then it works again.
But bottom-line is you can't have two route statements for the same route.
IF it's truly a standby router then it should handle the function itself - you shouldn't have to add anything to the local system. Just add the route to the device & let the two devices decide amongst themselves which will handle the traffic.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Ron Kinner
Honored Contributor

Re: standby route

I think that unless you are running GATED that the metric is only used to decide if the route is local or remote.

From man route(1M):

"count An integer that indicates whether the gateway is a remote host or the local host. If the route leads to a destination through a remote gateway, count should be a number greater than 0. If the route leads to destination and the gateway is the local host, count should be 0. The default for count is zero. The result is not defined if count is negative. "

and

"Flags

The values of the count and destination type fields in the route command determine the presence of the G and H flags in the netstat -r display and thus the route type, as shown in the following table.


Count Destination Type Flags Route Type
=0
network
U
Route to a network directly from the local host

>0
network
UG
Route to a network through a remote host gateway

=0
host
UH
Route to a remote host directly from the local host

>0
host
UGH
Route to a remote host through a remote host gateway

=0
default
U
Wildcard route directly from the local host

>0
default
UG
Wildcard route through a remote host gateway"

From man routing(7):

"To select a route for forwarding an IP packet, the network facilities select the complete set of "matching" routing table entries from the routing table. A routing table entry is considered a match, if the result of the bit-wise AND operation between the netmask in the routing entry and the IP packet's destination address equals to the destination address in the routing entry.

The network facilities then select from the set the routing entries that have the longest netmask. The length of a netmask is defined as the number of contiguous 1 bits starting from the leftmost bit position in the 32-bit netmask field. In other words, the network facilities select the routing entry that specifies the narrowest range of IP addresses. For example, the host route entry that has a destination/netmask pair of (147.253.56.1, 0xffffffff), is more specific than the network route entry that has a destination/netmask pair of (147.253.56.0, 0xfffffe00), therefore the network facilities select the host route entry. The default route by default has a destination/netmask pair of (0,0). Therefore the default route matches all destinations but it is also the least specific. The default route will be selected only if there is not a more specific route.

There may still be multiple routing entries remaining. In that case the IP packet is routed over the first entry displayed by netstat -r. Such multiple routes include:

Two or more routes to a host via different gateways.

Two or more routes to a network via different gateways.

Two default routes. "

It appears that the order they are listed in netstat -r is critical. I wonder if you change router2's name by adding a "z" in front if it would then appear second. (I assume that they are not really named router1 and router2.) Your other possibility would be to use 172.19.0.0 netmask 255.255.0.0 for router2. This would be a poorer match than router1 so would always let router1 have first crack at the traffic.


As Jeff said tho, normally you would set up the both routers using HSRP (Hot Standby Router Protocol) which would then automatically switch between routers without the host being aware of the change. With HSRP the two router create a virtual IP and MAC which is used as the gateway by all hosts and whichever is prime responds to any traffic to the virtual address. The backup one only responds if the prime dies.

Ron
John Waller
Esteemed Contributor

Re: standby route

Many thanks for the info, I liked the idea of changing the netmask to try and fool the system but this does not work if the first router fails. Unfortunatly the routers we have are only very basic and cannot handle HSRP so I have a non-starter.
PVR
Valued Contributor

Re: standby route

The last parameter in the route statement is hop count not metrix.

I think.........

In the routing table, mention only one route pointing to router1 and put another router's static IP as the default gateway.
Don't give up. Try till success...
Ron Kinner
Honored Contributor

Re: standby route

You may want to try turning on gated to get it to work correctly as a backup route.

Ron