I've been doing a bit of work on geting this working, but have hit a wall..
I followed the info at http://wiki.openwrt.org/multipleWan but as I don't use dhcp on my wan sides, I have constructed the following script which I am currently running manually - this is intended to work as a drop-in generic script, btw, with any number of links, not simply 2, and no hardcoded addresses!!
#!/bin/sh
#
#
# OpenWRT iproute2 routing file for multiple WAN links.
# (C)2007 Robert O'Donnell. robert@irrelevant.com.
#
# BSD licence: quickly - you are free to copy and use this in any form
# as long as you retain the above copyright notice.
#
# inspired by:
# http://wiki.openwrt.org/multipleWan?action=recall&rev=1 by benoitm974
# http://lukav.com/wordpress/2007/03/12/openwrt-multi-wan-how-to/ by lukav
# http://lartc.org/howto/lartc.rpdb.multiple-links.html
#
# This was designed for an environment where all WAN links are static
# addressing and routing.
#
# You also need to do the mods to /etc/config/network and install the
# ip packages as described on the wiki page above.
#
# /etc/iproute2/rt_tables should be:
# 201 wan
# 202 wan2
#
# NOTE- This script should cope with an indeterminate number of WAN links!
# table name should be same as section name in /etc/config/network
#
#
. /etc/functions.sh
include /lib/network
scan_interfaces
ROUTE_FILE="/etc/route/route_"
ifcmd="ip route add default scope global "
# set up basic routing for each (wan) subnet
for ifc in $interfaces; do
config_get proto $ifc proto
if [ $ifc != "loopback" -a $ifc != "lan" -a $proto = "static" ]
then
config_get ifname $ifc ifname
config_get gateway $ifc gateway
config_get netmask $ifc netmask
config_get ipaddr $ifc ipaddr
config_get proto $ifc proto
eval $(ipcalc.sh "$ipaddr" "$netmask") # this sets $NETWORK and $PREFIX
ip route flush table $ifc
# this network
ip rule add from $ipaddr table $ifc
ip route add $NETWORK/$PREFIX dev $ifname src $ipaddr table $ifc
ip route add default via $gateway table $ifc
# and add to main table
ip route add $NETWORK/$PREFIX dev $ifname src $ipaddr
# add to load balancing command..
ifcmd="$ifcmd nexthop via $gateway dev $ifname weight 1"
fi
done
# add direct routes to other subnets to each wan table.
for ifc in $interfaces; do
if [ $ifc != "loopback" -a $ifc != "lan" ]
then
for ifc2 in $interfaces; do
if [ $ifc != $ifc2 ]
then
config_get ifname $ifc2 ifname
config_get netmask $ifc2 netmask
config_get ipaddr $ifc2 ipaddr
eval $(ipcalc.sh "$ipaddr" "$netmask") # this sets $NETWORK and $PREFIX
ip route add $NETWORK/$PREFIX dev $ifname table $ifc
fi
done
fi
done
# kill any existing default routes
while route del default >&- 2>&- ; do :; done
#execute load balancing default route command :-)
eval $ifcmd
My issue currently is that although the routing looks ok, I can't traceroute out via wan2 (I can ping the router on that side, though - only trying to go further times out on first hop..)
root@OpenWrt:/etc/init.d# ip route list
192.168.0.0/24 dev br-lan proto kernel scope link src 192.168.0.36
192.168.13.0/24 dev eth0.1 proto kernel scope link src 192.168.13.3
192.168.12.0/24 dev eth0.2 proto kernel scope link src 192.168.12.3
default
nexthop via 192.168.13.1 dev eth0.1 weight 1
nexthop via 192.168.12.1 dev eth0.2 weight 1
root@OpenWrt:/etc/init.d# ping -c 1 192.168.12.1
PING 192.168.12.1 (192.168.12.1): 56 data bytes
64 bytes from 192.168.12.1: icmp_seq=0 ttl=255 time=2.7 ms
--- 192.168.12.1 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 2.7/2.7/2.7 ms
root@OpenWrt:/etc/init.d# traceroute 82.xxx.xxx.65
traceroute to 82.xxx.xxx.65 (82.xxx.xxx.65), 30 hops max, 38 byte packets
1 * * *
2 *
root@OpenWrt:/etc/init.d# traceroute 82.xxx.xxx.66
traceroute to 82.xxx.xxx.66 (82.xxx.xxx.66), 30 hops max, 38 byte packets
1 192.168.13.1 (192.168.13.1) 2.226 ms 1.733 ms 2.219 ms
2 yyy.yyy.uk.easynet.net (87.yyy.yyy.106) 64.569 ms 49.042 ms 63.704 ms