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
There isn't going to be a difference to your routing. Whatever gateway comes first in your routing table is going to be used first. You can add the one that you want to use as the primary gateway in ifcfg-ethx of your first interface. Then you should see two entries in your routing table (along with the usual entries and information):
Destination Gateway Genmask Interface 0.0.0.0 (The address of your first gateway) 0.0.0.0 eth0 0.0.0.0 (The address of your second gateway) 0.0.0.0 eth1
On 5/25/06, Tom Brown tom@ng23.net 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@centos.org http://lists.centos.org/mailman/listinfo/centos
On Thursday 25 May 2006 08:35, Joshua Gimer wrote:
There isn't going to be a difference to your routing. Whatever gateway comes first in your routing table is going to be used first. You can add the one that you want to use as the primary gateway in ifcfg-ethx of your first interface. Then you should see two entries in your routing table (along with the usual entries and information):
Destination Gateway Genmask Interface 0.0.0.0 (The address of your first gateway) 0.0.0.0 eth0 0.0.0.0 (The address of your second gateway) 0.0.0.0 eth1
On 5/25/06, Tom Brown tom@ng23.net 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@centos.org http://lists.centos.org/mailman/listinfo/centos
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
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Thu, May 25, 2006 at 11:51:14AM +0100, Tom Brown wrote:
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?
What are you trying to accomplish ? Load balancing ? Redundancy ?
- -- Rodrigo Barbosa rodrigob@suespammers.org "Quid quid Latine dictum sit, altum viditur" "Be excellent to each other ..." - Bill & Ted (Wyld Stallyns)
Le Jeudi 25 Mai 2006 12:51, Tom Brown a écrit :
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
Hello,
I think setting /etc/sysconfig/network-scripts/route-ethX files will help, see http://blog.subverted.net/?p=571
Vincent Knecht wrote:
Le Jeudi 25 Mai 2006 12:51, Tom Brown a écrit :
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
Hello,
I think setting /etc/sysconfig/network-scripts/route-ethX files will help, see http://blog.subverted.net/?p=571
No that won't work. He wants packets to go out through their respective gateways depending on the NIC ip address. He does not want static routes which is a case of all packets to network Y, use ethX.
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@centos.org 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
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@graffiti.net 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@centos.org 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@centos.org http://lists.centos.org/mailman/listinfo/centos
On Friday 26 May 2006 08:30, Joshua Gimer wrote:
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@graffiti.net 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@centos.org 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@centos.org http://lists.centos.org/mailman/listinfo/centos
Just a tiny weebit of iproute2 will do the job, if you have static ip's it's just a matter of adding 4 lines to rc.local just like i explained on my other post.
ip rule .. ip route ..
;)
I've done some work on this a few month ago at my other job, and
basically
the solution lies in iproute2 commands.
You will find detailed instructions on managing multihomed hosts with iproute2 in the Linux Advanced Routing and Traffic Control HOWTO, available at http://lartc.org .
If it is just for static routes on a system with multiple nics, I prefer using the route-<interface> in sysconfig.
i.e. /etc/sysconfig/network-scripts/route-eth1
192.168.1.0/24 via 10.0.0.250
192.168.2.0/24 via 10.0.0.250
192.168.3.0/24 via 10.0.0.250
This way the routes get cleaned up and re-added with an /etc/init.d/network restart, unlike /etc/rc.local
J.J.