I'm trying to set up a Debian box as a router for an office. I need to have 3 subnets in the LAN and 2 WAN connections, and I want one of the subnets to ALWAYS use WAN 1 and the other subnet to ALWAYS use WAN 2 (no load balancing).
For exmaple, I want to have these three subnets: - 10.1.1.0/24 - 10.1.2.0/24 - 10.1.3.0/24
I want 10.1.1.0/24 to go out to the Internet using ISP #1 and 10.1.2.0/24 and 10.1.3.0/24 to use ISP #2.
And one second level of complication: ISP #2 is a DSL connection with a dynamic IP address.
I think this should be easy to implement, but I've never done it before and I haven't been able to find an example online. I've been reading lartc but I couldn't adapt the examples they provide to what I want to do.
I'll appreciate any lead!
You will have to look at source based routing. In essence you would setup two routing tables and use iptables to tag the traffic to use one of the routing tables.
I would keep the default route on the ADSL line and use a custom routing table for the other WAN link. This assumes that isp1(ADSL) is on eth0 and correctly configured and isp2(static) is on eth1.
You would also have to setup NAT.
On your dynamic interface you would use:
And on the static interface
You can do this with
ip rule
and friends (keyword: source based routing). First you need to build another routing table. Lets call it wan2. add it to/etc/iproute2/rt_tables
Fortunately the output of ip route is in the same format as the input. You can do this to copy the table (without default route)
Then add the default route
When finished you can use the
ip rule
command to build rules to select the corresponding routing table:I found this script somewhere in the internet, but forgot where. You can use it as template