Operating System - HP-UX
1823124 Members
3241 Online
109646 Solutions
New Discussion юеВ

I have two network card,How can I set gateway for each of it ?

 
SOLVED
Go to solution
xiongye_2
Occasional Advisor

I have two network card,How can I set gateway for each of it ?

My hp-ux box has two netwotk cards,and connect to different network,how can I configure different gateway for each of it ,Using SAM just config one default gateway, or vi /etc/rc.config.d/netconf ? Thanks !
xysco
4 REPLIES 4
Sridhar Bhaskarla
Honored Contributor
Solution

Re: I have two network card,How can I set gateway for each of it ?

Hi,

There can be only one 'default' gateway per system. If that gateway cannot take care of default routing, you can configure static routes for the other router. Say your routers are 10.10.10.1 and 20.20.20.1 then you would run

#route add default 10.10.10.1 1

#route add net 30.30.30 netmask 255.255.255.0 20.20.20.1 1
#route add net 40.0.0 netmask 255.0.0.0 20.20.20.1 1

etc.,

Your /etc/rc.config.d for the above would be

ROUTE_DESTINATION[0]=default
ROUTE_MASK[0]="255.255.255.0"
ROUTE_GATEWAY[0]="10.10.10.1"
ROUTE_COUNT[0]=1

ROUTE_DESTINATION[1]="net 30.30.30"
ROUTE_MASK[1]="255.255.255.0"
ROUTE_GATEWAY[1]="20.20.20.1"
ROUTE_COUNT[1]=1

ROUTE_DESTINATION[2]="net 40.0.0"
ROUTE_MASK[2]="255.0.0.0"
ROUTE_GATEWAY[2]="20.20.20.1"
ROUTE_COUNT[2]=1

You can keep addding modules like the above in netconf file for each static route. Make sure the index is unique for each static route. Depending on the configuration of the router, you will need to specify the corresponding ROUTE_MASKs.


-Sri
You may be disappointed if you fail, but you are doomed if you don't try
nibble
Super Advisor

Re: I have two network card,How can I set gateway for each of it ?

edit /etc/rc.config.d/netconf for additional static routes but you have to set only one default route.
Greg OBarr
Regular Advisor

Re: I have two network card,How can I set gateway for each of it ?

I don't believe you "HAVE" to have a default route, but you won't be able to reach any subnets for which you don't have a defined route if you don't. i.e., if you had 2 interfaces lan0 and lan1:

lan0: 10.10.10.5
route add net 10.10.10 netmask 255.255.255.0 10.10.10.5 1

lan1: 20.20.20.7
route add net 20.20.20 netmask 255.255.255.0 20.20.20.7 1

Then you'd have to run a routing daemon. It used to be "routed". Now I think it's called "mrouted". You wouldn't be able to reach any addresses other than 10.10.10.[1-254] and 20.20.20.[1-254].

Then if you ran:

route add default inet 10.10.10.5 netmask 255.255.255.0 1

You'd go through the lan1 interface to get to 20.20.20.x addresses and 10.10.10.5 addresses for everything else.
rick jones
Honored Contributor

Re: I have two network card,How can I set gateway for each of it ?

If you use ndd to enable ip_strong_es_model then one of the side effects of the inclusion of source IP address in route selection is functionality that is quite close if not the same as having a default route per interface.

There are other side effects - traffic will only be accepted on the interface with the patching IP address.

How well it works when apps do not bind() to IPs prior to calling connect() I do not know. It does seem to work the other way around - that is with applications that are calling accpet() - as the remote client has pretty much selected our local IP by its choice of destination IP address in the IP datagram carrying the TCP SYN segment.

How "supported" it is I am not sure.
there is no rest for the wicked yet the virtuous have no pillows