Operating System - Linux
1827756 Members
2932 Online
109969 Solutions
New Discussion

Re: Adding two new nics and creaing the default gateway for each

 
Mike Hedderly
Advisor

Adding two new nics and creaing the default gateway for each

I am using Redhat linux As4

I already have Bond0 created with a defualy gateway, but I haave added two ned nics, eth2 and eth3.


This is the setup
Eth2 ip address 10.134.30.42 subnet 255.255.255.128 default gateway 10.134.30.1

Eth2 ip address 10.134.30.170 submet mask 255.255.255.128 default gateway 10.134.30.129

I would like to define a default gateway for each Nic.

So all traffic going out from eth2 routes via 10.134.30.1 and all traffic going from eth3 routes via 10.134.30.129


2 REPLIES 2
Jeeshan
Honored Contributor

Re: Adding two new nics and creaing the default gateway for each

set iptables roules.
a warrior never quits
Matti_Kurkela
Honored Contributor

Re: Adding two new nics and creaing the default gateway for each

And when an outgoing packet has a destination of, say, 123.45.67.89, which NIC or bond should it use then? Is there only one good option, or might there be another gateway that is not as good but might be used if the primary gateway does not work?

Remember that there are no such things as "connections" or "sessions" on the IP level: by default, each packet is routed using its own address information and nothing else.

The "default gateway" is what is used if the routing table has no more specific instructions for a particular destination address.

You have listed two new gateways, in addition to the old default gateway. Is the entire IP address space of the whole Internet truly reachable through all these three gateways?

If yes, the destination IP address alone is insufficient for determining the correct outgoing network interface. This is where the traditional routing table and the "route" command become inadequate: you must use the advanced techniques of "policy routing", and the command for configuring it is "ip".
See:
http://www.policyrouting.org/PolicyRoutingBook/ONLINE/TOC.html


If no, then some of these gateways are not really "default" gateways, but just "limited" gateways to some definable sub-sets of IP addresses. This can be handled using a traditional routing table: when setting up the route manually, instead of "route add default gw ", you specify one or more commands like "route add -net netmask gw ". To make these settings permanent, you should create files like /etc/sysconfig/network-scripts/route-.

For example, if your eth2 has connectivity to 10.134.20.0/255.255.255.0 and 10.134.21.0/255.255.255.0 and eth3 to 10.133.0.0/255.255.0.0, you could write two files:

/etc/sysconfig/network-scripts/route-eth2:
ADDRESS0="10.134.20.0"
NETMASK0="255.255.255.0"
GATEWAY0="10.134.30.1"

ADDRESS1="10.134.21.0"
NETMASK1="255.255.255.0"
GATEWAY1="10.134.30.1"

/etc/sysconfig/network-scripts/route-eth3:
ADDRESS0="10.133.0.0"
NETMASK0="255.255.0.0"
GATEWAY0="10.134.30.129"

MK
MK