my configuration reference: https://www.lartc.org/howto/lartc.rpdb.multiple-links.html
Just a router with 2 WANs, I am trying to use routing for load balancing. But it doesn't work. I would be very much grateful if someone could kindly advise me on
WAN1(eth1): Static 8.8.8.8, Gateway: 8.8.8.9
WAN2(eth2): Static 9.9.9.9, Gateway: 9.9.9.10
My configuration:
Step 1: Create two routing tables
echo "251 T1" >> /etc/iproute2/rt_tables
echo "252 T2" >> /etc/iproute2/rt_tables
Step2:
For direct connection subnet 8.0.0.0/8, use WAN1
ip route add 8.0.0.0/8 dev eth1 src 8.8.8.8 table T1
ip route add default via 8.8.8.9 table T1
For direct connection subnet 9.0.0.0/8, use WAN2
ip route add 9.0.0.0/8 dev eth2 src 9.9.9.9 table T2
ip route add default via 9.9.9.10 table T2
Step3: The following 4 command line are to ensure that the data go through(out/in) the same WAN port
Make sure the correct ingress (from) is selected.
ip route add 8.0.0.0/8 dev eth1 src 8.8.8.8
ip route add 9.0.0.0/8 dev eth2 src 9.9.9.9
Make sure the correct outlet is selected. :
ip rule add from 8.8.8.8 table T1
ip rule add from 9.9.9.9 table T2
**Step4:**The last command line below is not suitable for openwrt, so it has to be changed as follows
original: ip route add default scope global nexthop via $P1 dev $IF1 weight 1 nexthop via $P2 dev $IF2 weight 1
changed to: ip route add default nexthop via 9.9.9.10 metric 5 <--this is secondary default route
The problem comes from the secondary default route: <e.g. traceroute 99.99.99.99> next hop always is 8.8.8.8 (I think it should be 8.8.8.9), even WAN1 (eth1) is unplugged, I expect all the traffic at this time go through this secondary default route (WAN2), but the next hop is still 8.8.8.8
root@OpenWrt:~# traceroute 99.99.99.99
traceroute to 99.99.99.99 (99.99.99.99), 30 hops max, 46 byte packets
1 **8.8.8.8** (8.8.8.8) 3144.170 ms !H 3155.131 ms !H 3119.875 ms !H
root@OpenWrt:~# ip route show
default via 8.8.8.9 dev eth1
default via 9.9.9.10 dev eth2 metric 5
8.0.0.0/8 dev eth1 scope link src 8.8.8.8
8.8.8.0/24 dev eth1 scope link src 8.8.8.8
9.0.0.0/8 dev eth2 scope link src 9.9.9.9
9.9.9.0/24 dev eth2 scope link src 9.9.9.9
192.168.1.0/24 dev br-lan scope link src 192.168.1.1
root@OpenWrt:~# ip rule list
0: from all lookup local
32764: from 9.9.9.9 lookup T2
32765: from 8.8.8.8 lookup T1
32766: from all lookup main
32767: from all lookup default
root@OpenWrt:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 8.8.8.9 0.0.0.0 UG 0 0 0 eth1
0.0.0.0 9.9.9.10 0.0.0.0 UG 5 0 0 eth2
8.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 eth1
8.8.8.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
9.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 eth2
9.9.9.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan