Click to See Complete Forum and Search --> : Routing Multiple Gateways with Linux


chenry3
02-19-2003, 05:18 PM
Well, I've been sort of browsing the forums, and haven't really noticed anyone ask this, so sorry if this is a repeat... but anyway

I'm running Debian 3.0 and everything works beautifully except I can't figure out how to do my routing. Here is my setup:

eth0: internal network: 192.168.0.1/255.255.255.0 - static
gateway: 192.168.0.150

eth1: wan connection: *.*.*.96/255.255.255.0 - dhcp via isp
eth2: wan connection: *.*.*.70/255.255.255.0 - dhcp via isp
eth3: wan connection: *.*.*.86/255.255.255.0 - dhcp via isp
eth1,eth2,eth3 have same isp gateway, and are on same subnet.

*NOTE: I'm not running routing through my linux box, just hosting services

Anyway, my problem is that I cannot figure out how to setup each nic to use it's own gateway to respond. For instance, when I put them all up, I get no connectivity except to my local subnets because there is no default router. I set my internal router as default (192.168.0.150) and I get connectivity to the internet through my local network, but eth1,eth2 and eth3 will not work on the net. If I change my default route to use eth1, 2 or 3, then the appropriate one will work and the others will not. I'm assuming that any incoming connection to one of those tries to respond via the default gateway and thus nothing is accomplished. I'm trying to figure out a way to setup my routing (I may have to install ipmasq or iptables... I wouldn't think so tho...) so that each nic will respond with whichever gateway it has assigned. In other word I want to be able to host services on all 3 wan ips, and use my internal ip as a default route to the net. Any ideas?? and I hope I was clear with my problem... let me know if I wasn't :)

-Chris

cowanrl
02-20-2003, 11:08 PM
If I understand what you are trying to do, you aren't going to be able to accomplish it using routing alone. You'll need help from some higher layer protocol or application.

It looks to me like you want to have, for example:

www.domain1.com = *.*.*.96
www.domain2.com = *.*.*.70
www.domain3.com = *.*.*.86

If someone accessed www.dodmain1.com, the packet would be received on eth1. You'd like the packet to be sent back out eth1 with a source address of *.*.*.96.

To do this, you need some application that can bind each ethernet interface with it's own virtual IP stack that had it's own routing table.
I know you can do something like that with IIS in the Windows world. I would imagine you could do something like it with Apache though I have no experience with it.

Trying to accomplish it just by using a default gateway won't work.

chenry3
02-21-2003, 04:40 PM
you were right, I did need the help of a higher level routing protocol. I ended up using iproute. That allows you to setup x amount of routing tables, and bind whichever routing table you want to any device. I thank my good friend for helping me out with it :)

-Chris

cowanrl
02-22-2003, 11:18 AM
I always learn something new on this site. I've never investigated the ip command that deeply before.

I'd like to understand exactly how you did it. Did you use

ip route add table TABLEID <route info>

to create the different route tables and then use:

ip rule add iif INTERFACE table TABLEID

to bind the route table to the desired interface?

It would be interesting if you could post your ip rule list here so I can check it out.

Thanks