OpenWrt Forum Archive

Topic: DUAL WAN setup help

The content of this topic has been archived on 26 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

II've separated port 4 from the bridge on my wrt, and its now connected to a second cable modem (on top of the one connected to the WAN port).
both modems get an ip from different ISP's via dhcp.

http://www.gliffy.com/pubdoc/1143760/L.jpg

As shown on the diagram on the link above, I'd like:
- computers on the network (C1 for example) to go only through ISP AA
- C2 should go by default through ISP AA
- when outgoing ports are 20000-22000, C2 should use ISP BB


I've read numerous links and searched the forums on DUAL wan, multiple gateways, etc, but with my limited networking knowledge I've failed to get this setup working correctly and would like your help.

could anyone please post their working setup or help me config mine ?

You would need to start at the LARTC, the Linux Advanced Routing and Traffic Control  HowTo document. Look at http://www.lartc.org/

Don't expect the simple solutions implemented there to support transparent failover, or other traffic balancing or anything like that.   This is a lot harder than it sounds.

for starters i used rhashimoto's solution which worked quite well (mbm's link should work in a similar manner but for some reason didnt..)
I might look into traffic balancing in the future, as the current solution might work well for me.

When your two WAN interfaces come up does DHCP assign a default route for each interface?  Mine does that, and it was a little annoying hashing out a script to automatically fix it.   Is there an easy way to prevent that from happening?   I'm reproducing the script I use here in case someone else wants it (warning: it's my first bash script so it's a little ugly).   The script uses "ip route list" to find out what default gateways have been assigned, deletes the one I don't want (vlan1, that goes to my slower DSL modem) and then creates a new routing table (4) for the vlan1 interface.

#! /bin/sh
COUNT=1
ADDR=12
ip route list | grep default \
 |  while read FIELD
     do
       if [ "$COUNT" -eq "1" ]
       then
         echo $FIELD
         ADDR=`echo $FIELD | awk '{print $3}'`
         DEV=`echo $FIELD | awk '{print $5}'`
         COUNT=2
       elif [ "$COUNT" -eq "2" ]; then
         echo $FIELD
         ADDR1=`echo $FIELD | awk '{print $3}'`
         DEV1=`echo $FIELD | awk '{print $5}'`
         if [ "$DEV1" = "vlan1" ]
         then
           ip route delete default via $ADDR1
           ip route add table 4 via $ADDR1 dev $DEV1
         else
           ip route delete default via $ADDR
           ip route add table 4 via $ADDR dev $DEV
         fi
       else
         echo 'ERROR'
       fi
     done

The discussion might have continued from here.