Re: [CentOS] CentOS 4.x - Multiple gateways

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi,

I've done some work on this a few month ago at my other job, and basically
the solution lies in iproute2 commands.

First you need to create a rule and assign that traffic to a different table
than the main table. Then you can easily add a default route to that new
table.

so it would look like this

ip rule add from 192.168.1.0/24 table X

check /etc/iproute2/rt_tables if you want to make aliases like eth1 eth2 eth3
it will get easier if you automate this thing :)

After that you set a default route to this new table.

ip route add default via 1.2.3.4 table X


Once you have this done and working it's a matter of getting your
dhclient of pppoe to do this for you as soon as ip changes.

for pppoe create a /etc/ppp/ip-up.local script.
for dhclient stuff you need to look in /sbin/dhclient-script script to find
out how it will execute what's in /etc/dhclient-enter-hooks
or /etc/dhclient-exit-hooks

It's quite useful and for me it did turn out to work nicely. I just had to
create some sort of master script that would take decisions on what's going
on with my gateways :) It was pretty fun to work on that. I hope this helps
you out.

Later,
Charles


On 5/26/06, Feizhou < feizhou@xxxxxxxxxxxx> wrote:
Tom Brown wrote:
> Hi
>
> On a multihomed box how can i set different gateways for each NIC?
> Setting them in the ifcfg-ethx does not seem to make any difference to
> the routing?
>
> thanks
> _______________________________________________
> CentOS mailing list
> CentOS@xxxxxxxxxx
> http://lists.centos.org/mailman/listinfo/centos

Try creating routing tables per NIC, populating those tables and
creating ip rules to lookup the respective table. This means you need to
identify which NIC the packets belong to. You can try adding rules to
the mangle PREROUTING chain of netfilter to mark the packets based on
their source ip. Then the ip rules can instruct the kernel to lookup the
proper routing table depending on the firewall mark.

man ip, man iptables, http://linux-ip.net/html/routing-tables.html and
http://linux-ip.net/html/tools-ip-route.html

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos



--
Thx
Joshua Gimer
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux