Operating System - HP-UX
1833875 Members
1911 Online
110063 Solutions
New Discussion

Re: Two default gateways??

 
SOLVED
Go to solution
Dermot Beirne
Frequent Advisor

Two default gateways??

Hi,
I have two nic's in my K250 running 10.20. Each has an address on two different networks, i.e.
lan0 = 193.10.10.1
lan1 = 10.10.10.1
I want to ensure that traffic destinated for the 193 address returns with a source address of 193.10.10.1.
Can I specify two default gateways, one for lan0 and one for lan1, so that i can ensure that traffic coming from 163.10.10.1 returns via lan0 with a 193 address.

If so, how is this done.
Thanks
Dermot.
Happy is harder than money. Anyone who thinks money will make them happy, doesn't have money.
11 REPLIES 11
Yogeeraj_1
Honored Contributor

Re: Two default gateways??

netstat -r
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Domenico_5
Respected Contributor
Solution

Re: Two default gateways??

yes

you must edit netconf file and add this lines

for secondary lan
ROUTE_DESTINATION[1]=default
ROUTE_MASK[1]=""
ROUTE_GATEWAY[0]=xxx.xxx.xxx.xxx
ROUTE_COUNT[0]=
ROUTE_ARGS[0]=

where [1] is you secondary lan

regadrs

S.K. Chan
Honored Contributor

Re: Two default gateways??

The best way to make these addition permanent is to edit /etc/rc.config.d/netconf. For example ..

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

ROUTE_DESTINATION[1]=default
ROUTE_MASK[1]=""
ROUTE_GATEWAY[1]=
ROUTE_COUNT[1]=1
ROUTE_ARGS[1]=""



MANOJ SRIVASTAVA
Honored Contributor

Re: Two default gateways??

You specificy default gateway for each card seperatley like this

ROUTE_DESTINATION[0]=default
ROUTE_MASK[0]=""
ROUTE_GATEWAY[0]="10.2.10.1"
ROUTE_COUNT[0]=""
ROUTE_ARGS[0]=""


ROUTE_DESTINATION[1]=
ROUTE_MASK[0]=""
ROUTE_GATEWAY[1]="20.2.10.1"
ROUTE_COUNT[0]=""
ROUTE_ARGS[0]=""


or u can use sam

you may like to read this document too:

http://www1.itrc.hp.com/service/cki/docDisplay.do?docId=200000049791567



Manoj Srivastava
Dermot Beirne
Frequent Advisor

Re: Two default gateways??

Hi,
Thanks for your help.
That sounds like what I am looking for. I presume that I can then just do a

route add net 163.x.x.x 193.x.x.x 1

to make all any traffic going from 163.x.x.x go back through 193.x.x.x card with and 193.x.x.x source address.

Dermot.
Happy is harder than money. Anyone who thinks money will make them happy, doesn't have money.
Ron Kinner
Honored Contributor

Re: Two default gateways??

Putting in the route to the network is the correct thing to do. Routing decision are based on where you want to go not which NIC the original packet came in on. However you will also want to put it in the /etc/rc.config.d/netconf file so that it remains after a reboot.

Having two default gateways makes no sense since by definition the default gateway is the one you use when you have no better route. How could you choose between two default gateways? I'd be surprised if it even lets you have two defaults.

Window boxes allow (and even encourage because people feel they should fill in all of the blanks in the setup form) having a default gateway for each NIC and this causes no end of grief since the one which shows up at the top of the routing table is the one which is used all of the time. The other one will never be used. I have to fix this kind of stuff all of the time.

Rule is the default gateway points toward the internet or to the network which has access to the largest number of different networks. Routes to all remaining networks have to be added via routing statements unless you are using RIP or OSPF or other dynamic routing protocol.

When you edit the /etc/rc.config.d/netconf file watch out for the numbers in the []'s. They should be consistent and sequential.

Ron
Jeff Schussele
Honored Contributor

Re: Two default gateways??

Hi Dermot,

I have to agree w/Ron.
I've never even tried to set up 2 default routes.
If I want "special" routes, I set up static routes to either hosts or nets - usually nets.

Just set up a static route to the 163.10.10 net & designate 193.10.10.1 as the gateway with a hop count of 0.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Dermot Beirne
Frequent Advisor

Re: Two default gateways??

I see your point about not having 2 default gateways.
I have set the default gateway to be 10.x.x.x but i still had to specifically add a route for anything I wanted to route to via that gateway. It does not appear to be using it as it's default. I cannot figure out why. Now, no mail is being sent off the machine as it is unable to resolve any domain names any longer. I am assuming that it does not know where to send DNS requests if it cannot resolve them itself, but i do not know what route to add to fix this if it does not use it's default.
Any suggestions,
Thanks Dermot.
Happy is harder than money. Anyone who thinks money will make them happy, doesn't have money.
John Palmer
Honored Contributor

Re: Two default gateways??

Hi,

Please post the output from:
1. netstat -in
2. netstat -rnv
3. cat /etc/nsswitch.conf
4. cat /etc/resolv.conf

Regards,
John
Dermot Beirne
Frequent Advisor

Re: Two default gateways??

I got it!!
I have not seen it before, but a unix friend of my suggested that I delete the default route, and add it back in without the use of the word default, i.e.

route add net 0.0.0.0 netmask 0.0.0.0 1

I had already done this myself, but did not do a route delete default beforehand.
As soon as I deleted the default route and then entered the above command, everything started working fine.
I do not know if this is a bug, or what, but it may be useful to someone else.

Thanks to you all for your help.
Dermot.
Happy is harder than money. Anyone who thinks money will make them happy, doesn't have money.
John Palmer
Honored Contributor

Re: Two default gateways??

There isn't any difference between:
route add default ...
and
route add net 0.0.0.0

I suspect that you had an incorrect 'default' route in your routing table. When you deleted it, everything started working.

I'd still be interested in the output from netstat -rnv

Regards,
John