Subject: Re: Multiple default routes through different network interfaces?
To: Alicia da Conceicao <alicia@cyberstation.ca>
From: sudog <sudog@sudog.com>
List: port-i386
Date: 10/22/2001 14:28:50
Hello! :) I noticed your note to the netbsd mailing lists, and as a matter 
of fact, I know how to get the incoming routes properly configured. It 
requires using ipfilter and the fast routing abilities. Basically NetBSD 
isn't smart enough to know which interface a connection came IN on in that 
it routes it out whatever the "default route" is--even going so far as to 
use the wrong source IP address.

totally sucks.

But with IPFilter, you can use a rule like this:

pass out quick on fxp1 to fxp0:next.hop.ip from fxp0.ip.address/32 to any

in my case this would be:

pass out quick on fxp1 to fxp0:10.0.0.5 from 10.0.0.9/32 to any

This solves the problem in a very kludgy way. In my case, my 10.0.0.9 is 
the internal interface for an adsl gateway, and 10.0.0.5 is the internal 
interface for a cable gateway. it just answers as normal if connections 
come in from the adsl link. (the other side of the netbsd machine.)

Paul Vixie wrote a set of "default route" patches that fixed this 
behaviour. I believe these patches also might've fixed the annoying arp 
publishing problem, where, if you publish an arp entry NetBSD answers on 
all interfaces whether it already knows about the machine in its arp cache 
or not. So you have to use "real" routing from routing equipment and not 
just a simulated arp proxy-type thingy like you can with Linux.

There's another fellow who had some very cool modifications that sadly 
never seem to have made it into kernel--some kind of source 
routing/extending routing tables. Very cool.

I'm rambling: the other solution, using the outgoing interfaces in a 
round-robin like fashion, isn't something I've solved yet. Basically what 
I do is set up squid on one of my gateways and use my faster gateway as my 
default one for all traffic. Then, whenever I want to use another link (or 
two links at once) I quickly set my Opera proxy settings for new 
connections, and I can download through both links at once.

It's terrifically kludgy, but it works for me since my network is small, 
shared between a dynamic adsl and a dynamic cable, and no one else uses it 
but me.

Hope this helps--even a little. Check the ipfilter lists for "load 
balancing" and also the netbsd mailing list archives for "default route" 
and "load balancing" and "dual".

-marc

On Monday 22 October 2001 12:29, you wrote:
> Sorry to bother everyone again, but I was wondering if it is possible
> for a single NetBSD server to have multiple defaults routes on different
> network interfaces, that each have their own separate gateways?
>
> I have a PC running NetBSD-1.52, with two interfaces, each connected to
> a different ISP, and each with unique static IP number from the ISP's
> distinct network.  Neither ISP knows about the other, and neither ISP is
> willing to change their routers to route traffic for the other ISP's
> network.  The NetBSD-1.52 server has a kernel compiled with the GATEWAY
> option for packet forwarding.
>
> My goal is to have the following:
>
> 1) an incoming connection from a client computer with an arbitary IP
> number on the Internet to the static IP of one of the interfaces on the
> NetBSD server, has all responses for that connection routed back via the
> same interface and the gateway that corresponds to that interface
>
> 2) an outgoing connection from the NetBSD server to a client computer
>         with an arbitary IP number, can be routed via either interface
>         in a round-robin fashion, preferable with some type of interface
>         weight value that can be adjusted dynamically
>
> Cisco routers can do this, and so can Linux servers using a pseudo
> network interface, similar to the CCD pseudo device, that "joins" two or
> more real network interfaces into a pseudo network interface.  I would
> greatly appreciate any assistance in finding a solution for this to work
> on NetBSD.
>
> Would "routed" or "gated" help?  Remember that neither ISP is providing
> RIP, or any other type of routing discovery service.
>
> Thank you in advance.
> Sincerely,
> Alicia.
>
> PS. I have appended an example of what I mean...
>
> For example, if the NetBSD server is running the telnet service, and has
> two interfaces "eth0" & "eth1", and are configured as follows:
>
> eth0: inet 123.123.123.123 netmask 255.255.255.0 gateway 123.123.123.1
> eth1: inet 231.231.231.231 netmask 255.255.255.0 gateway 231.231.231.1
>
> And if that remote client computer has IP number 8.8.8.8
>
> Then from the client computer:
>
>         client> telnet 123.123.123.123
>
> all packets between the client & NetBSD server are routed only through
> the eth0 interface and go through the 123.123.123.1 gateway.  And
>
>         client> telnet 231.231.231.231
>
> all packets between the client & NetBSD server are routed only through
> the eth1 interface and go through the 231.231.231.1 gateway.
>
> Also from the NetBSD server:
>
>         server> telnet 8.8.8.8
>
> all packets between the NetBSD server and client are routed entirely via
> either the (eth0 interface + 123.123.123.1 gateway) or the (eth1
> interface + 231.231.231.1 gateway), with a 50%-50% chance (or some other
> weight).