OpenWrt Forum Archive

Topic: Dual Wan - Would This Work?

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

I have multiple broadband connections that I was hoping to load balance with my WRT54GS...

I know I can configure one (or more) of the LAN ports as additional WAN ports (just make them separate vlans).

The thing I don't know is what OpenWRT's "ip" command accepts...

I would *think* a command like the following would work:

ip route add default scope global equalize nexthop via xxx.xxx.xxx.xxx dev vlan1 nexthop via yyy.yyy.yyy.yyy dev vlan2

and

iptables -t nat -A POSTROUTING -s 192.168.0.1/24 -o vlan1 -j MASQUARADE
iptables -t nat -A POSTROUTING -s 192.168.0.1/24 -o vlan2 -j MASQUARADE

This *should* load balance outgoing connections.

Can anyone verify if this would work / fail miserably?

EOC_Jason wrote:

I have multiple broadband connections that I was hoping to load balance with my WRT54GS...

I know I can configure one (or more) of the LAN ports as additional WAN ports (just make them separate vlans).

The thing I don't know is what OpenWRT's "ip" command accepts...

I would *think* a command like the following would work:

ip route add default scope global equalize nexthop via xxx.xxx.xxx.xxx dev vlan1 nexthop via yyy.yyy.yyy.yyy dev vlan2

and

iptables -t nat -A POSTROUTING -s 192.168.0.1/24 -o vlan1 -j MASQUARADE
iptables -t nat -A POSTROUTING -s 192.168.0.1/24 -o vlan2 -j MASQUARADE

This *should* load balance outgoing connections.

Can anyone verify if this would work / fail miserably?

Well, adding another route shouldn't be a problem. But since iptables rules are read in a top down manner, the chance that the second rule there is ever invoked is slim'n'none.
So your load balancing would consist of masquerading different services to different connections, instead of just round robin.

This would probably fail because the "ip route equalize" is done on the network layer and not on the session layer. Because of masquerade your source ip adres will be translated into two different ip's. Two source adresses per session don't work.

Because of the connection oriented properties of TCP you will get a lot of resends. Your session will probably stay active/alive, but with lots of resends resulting in even a slower connection experience.

chankster wrote:

Well, adding another route shouldn't be a problem. But since iptables rules are read in a top down manner, the chance that the second rule there is ever invoked is slim'n'none.

This is not true, because it is a postrouting rule. So routing takes decision where to send packets, not the iptables rules. Above mentioned rules only apply masquerade. But you are still right stating that routing to multiple ISP's with masquerade should be done based on sessions.

(Last edited by Adze on 2 Oct 2005, 12:44)

Hello EOC_Jason, I'm not very clued up about this and im still a bit of a newb but couldn't you use IPRoute2 in order to load balance?

http://lartc.org/howto/lartc.rpdb.multi … tml#AEN298

That is part of the iproute2 howto, IProute2 (as far as I know) is used for QoS and traffic shaping so it may help you out if you find some guides on it. Sorry I cant help any further but I just thought it may be relevant.

Pulseammo wrote:

Hello EOC_Jason, I'm not very clued up about this and im still a bit of a newb but couldn't you use IPRoute2 in order to load balance?

http://lartc.org/howto/lartc.rpdb.multi … tml#AEN298

That is part of the iproute2 howto, IProute2 (as far as I know) is used for QoS and traffic shaping so it may help you out if you find some guides on it. Sorry I cant help any further but I just thought it may be relevant.

It is relevant. You need iproute2 (where the above mentioned 'ip' comes from) to manage this.
Using just the ip tool you can make sure one machine always uses one connection. That's called source-routing. But that's kind of crude in this kind of situation. You want to route based on sessions.
The way it works is that you can use netfilter (iptables) to mark packets, and then route depending on marks. See chapter 11 in the "Advanced Routing & Traffic Control" Howto (use teh google, luke).

Thanks for the feedback guys. I really would like to get this to work as I have 3 connections I would like to balance, and a 4-WAN router is very pricy. You guys have given me some different ideas how I might approach this. I'm going to go ahead and install opewrt on my router and start messing with it this afternoon.

Well if you can remember to set Boot_Wait on before you flash to openWRT. If you've already got the hardware then in the end you might as well try since the worst outcome prolly means flashing back to the linksys firmware. No harm in trying I guess. Boot_wait is handy to reflash if something goes wrong though.

EOC_Jason wrote:

Thanks for the feedback guys. I really would like to get this to work as I have 3 connections I would like to balance, and a 4-WAN router is very pricy. You guys have given me some different ideas how I might approach this. I'm going to go ahead and install opewrt on my router and start messing with it this afternoon.

Good luck, shouldn't be too hard getting the technical side of it working. Deciding which services and computers will use is another thing. smile
And in case it wasn't obvious, true transparent load balancing can only be done if the provider supports it, which requires the same provider and rarely then for home users.

I finally ditched the effort and got a hotbrick LB-2 off ebay cheap. It works like a charm. Oh well... maybe with a little more time, tinkering, and writing some custom load balancing code I might try to get my WRT to load balance more connections. I've kind of been peeling through some of the linksys GPL code for their multi-wan routers, but there's a lot to look through.

I wonder how the load balancing is done using hotbrick LB-2?
It would be nice to crack this using WRT54G. Cheapest LB-2 goes for ~$200 and wrt54g goes for $49. That sure sounds good. I'd love to hear comments from folks who have implemented the load balancing + QoS using WRT54g.

Just a newbie here but I seen load balancing mentioned in http://iptables-tutorial.frozentux.net/ … orial.html when I was researching how to do port forwarding.. It was for load balancing for two or more servers but I don't see why you can't get creative and do it in reverse..

/usr/local/fox

The discussion might have continued from here.