OpenWrt Forum Archive

Topic: Multi-WAN Load Balancing

The content of this topic has been archived between 29 Mar 2018 and 3 May 2018. Unfortunately there are posts – most likely complete pages – missing.

Hello, I installed multiwan 1.0.19, but it seems process stop after an error:

 ## Main Initialization ##
## Flushing IP Rules & Routes ##
## Clearing Rules ##
## IP Rules Initialization ##
## Refreshing Routing Tables ##
## IPTables Rule Initialization ##
## Creating FW Rules ##
## Refreshing DNS Resolution and Tables ##
## Refreshing Load Balancer ##
/usr/bin/multiwan: line 1: syntax error: 0 +

After that no process is present with name "multiwan".

Can you help me, please?

crisman wrote:

Hello, I installed multiwan 1.0.19, but it seems process stop after an error:

 ## Main Initialization ##
## Flushing IP Rules & Routes ##
## Clearing Rules ##
## IP Rules Initialization ##
## Refreshing Routing Tables ##
## IPTables Rule Initialization ##
## Creating FW Rules ##
## Refreshing DNS Resolution and Tables ##
## Refreshing Load Balancer ##
/usr/bin/multiwan: line 1: syntax error: 0 +

After that no process is present with name "multiwan".

Can you help me, please?

This is possibly yours truly's bad, forgetting to safe-guard missing configuration parameters. Can you ensure "weight" is specified and try it, again?

Turning on debug helps debugging smile. If the above suggestion doesn't help,  posting your /etc/config/multiwan may help me locate the cause of your trouble.

buildster wrote:

This is possibly yours truly's bad, forgetting to safe-guard missing configuration parameters. Can you ensure "weight" is specified and try it, again?

Turning on debug helps debugging smile. If the above suggestion doesn't help,  posting your /etc/config/multiwan may help me locate the cause of your trouble.

Sorry, it was a typo in my config ( a missing ' )...
Thanks

hi,
I've two wan on the same subnet and I'd like use multi wan. I know that this is a bad situation and that it can bypassed using a router to nat one wan but I can't do it.
Searching on the net I found this scenario: wiki.mikrotik.com/wiki/Manual:Load_balancing_multiple_same_subnet_links that is like mine. RouterOS is based on Linux so this approch should works also in openwrt, right?

Thank you for yout work!

Hey I have a question on this package. First of all, thank you for this great package, keep the good work up.

I'm running it on an TP-Link WR1043ND router with 10.03 RC3.

multiwan package is installed in version 1.0.19-1, version 1.0.17 and 1.0.18 spams the syslog because of my 3g connection.

luci-app-multiwan package is installed in version 1.0.16.

WAN is an K3765-HV USB dongle via 3g ppp flatrate on Vodafone.de net.

WAN2 is an 2,0/0,2 MBit DSL line (which is connected through an separate router) configured as static IP on the WAN port.

The failover does not work for me reliable on the 3g link. After a certain time it declares the connection as dead and disables it. But the modem is still connected (no disconnect in the syslog, the led of the usb dongle is still static on, so hwconnect is there). Also it does not try to do a reconnect. So useless in combination with 3g for me.

I tried different configs.

As 'dns' I tried auto and also the correct dns1/dns2 of my vodafone 3g, which are fixed.

As 'icmp_hosts' I tried www.vodafone.de, and also the dns or wan gateway.

As 'timeout' I tried from 3, 5 to 10 sec.

As 'health_fail_retries' I tried from 3, 5 to 10 tries.

And of course several combinations of that.

The result is always the same, after a certain time multiwan declares the 3g line as dead and disables it. No reconnect or anything else. But the line is up and running fine, I can see no disconnect on the syslog by chat or pppd and as reported the usb dongle also indicates an connect with an static led in blueish or greenish (3g or gprs) when connected.

The 3g is realized by pppd with comgt (and chat), so serial link.

So how to investigate on that issue?

I would appreciate any suggestions.

This is a really cool script.  I just got an OpenWRT capable router on Wednesday with the intention of using it to replace a debian box I'd been using as a router with custom routing scripts I made for multi-WAN.  This script really made my transition to OpenWRT easy!

My old custom method didn't have any failover, and I really love that about multiwan! 

I was thinking it'd be neat to make it so that you could set up the "Failover Traffic Destination" (failover_to) per "Traffic Rule" (mwanfw).  I have two ISPs, one very reliable but small transfer limits, the other completely unreliable but no traffic limits.  I have some traffic (80/443) which I'd like to failover from the unreliable ISP to the reliable ISP, but other traffic (bittorrent) I would never want to failover to the low-limit ISP.  I might be attempting to patch my multiwan to accomplish this, I'll be sure to report back in here.

I also have been monitoring the uptime of the unreliable connection for over 5 years; I'm thinking since multiwan also performs that sort of monitoring, maybe I'd throw in some hooks that'd enable it to report uptime statistics to an external program somewhere.  Not sure how useful that'd be to others but I guess if I make any customizations at all I'll post em here.

ok.. so recently update to most recent 10.03-rc4 on my router, previously running rc3. Its been a while since I've messed with it but at one time had all three of my dsl lines properly load balanced with multiwan 1.0.18. So I also update to the multiwan 1.0.19-1. Traffic only used one interface. So I removed and reinstalled 1.0.18 and restored my previously saved openwrt config. It then started using two interfaces "tested with a torrent d/l". Went back and forth between 18 and 19-1 experiencing the same results each time. So now I am back with 18 where I can use at least two lines but the third just sits idle.. configs look fine, same config for ever wan port. Here is the routing table.. notice only wan and wan2 have outgoing routes created.. why not the third?

Network     Target            IPv4-Netmask     IPv4-Gateway     Metric
lan             192.168.10.0  255.255.255.0     0.0.0.0               0
wan           98.0.0.0         255.0.0.0            0.0.0.0                0
wan3         65.0.0.0         255.0.0.0            0.0.0.0                0
wan2         74.0.0.0         255.0.0.0            0.0.0.0                0
wan2         0.0.0.0           0.0.0.0               74.243.46.1         0
wan           0.0.0.0           0.0.0.0               98.89.147.1         0

why cant I downgrade to < 1.0.19-1? There is a problem with this new script limiting me to only two wan connctions.. I have 3!
NVM, got 1.0.18 installed along with downgrading back to rc3 where once months ago all three of my wan circuits routed flawlessly, now its gone to hell after upgrading to rc4 and 1.0.19-1.. not sure exactly where to start other than the routing tables don't look like they should.. why wont it include my third wan into the routing table?

(Last edited by Black6spdZ on 24 Dec 2010, 02:03)

just a follow-up, I did a hard reset and reflash to backfire rc4 r24038, fresh install of luci-app-multiwan which in turn installed multiwan 1.0.19-1. Setup each of my dsl connections on different subnets and the load balancing is working now just as it used to.

Network Target IPv4-Netmask IPv4-Gateway Metric
wan3 192.168.3.0 255.255.255.0 0.0.0.0 0
wan2 192.168.2.0 255.255.255.0 0.0.0.0 0
wan1 192.168.1.0 255.255.255.0 0.0.0.0 0
lan 192.168.10.0 255.255.255.0 0.0.0.0 0
wan3 0.0.0.0 0.0.0.0 192.168.3.254 0
wan2 0.0.0.0 0.0.0.0 192.168.2.254 0
wan1 0.0.0.0 0.0.0.0 192.168.1.254 0

There are a couple problems however that I'm not sure how to track down. When the router is heavily loaded I lose wan connection peridically for 10 seconds or so and it comes back and will repeat this behavior. The router isn't restarting as the uptime counter shows. Also, I cant seem to get port forwarding to work.. will it not work with multiwan?

(Last edited by Black6spdZ on 28 Dec 2010, 21:26)

I'm running the build from 3 januari of Arokh on a Netgear WNDR3700 and have done the usb overlay thingy to have some more space.

But when I configure and run multiwan the system spontaniously reboots! Configuration of my network is very standard (LAN/WAN/WAN2) as is the configuration of multiwan. I don't enable multiwan during startup because I found it suspicious that the device became unreachable after installing it. And when I start it from /etc/init.d/multiwan the device reboots within seconds.

I putted set -xv in the top of the script and saw that the ssh session was broken after the iptable multiwan rules were configured. Can reproduce it when necessary.

I don't know if it's the netgear, it's configuration or multiwan, but it's pretty frustrating.

Configuration:

/etc/config/network

config 'interface' 'loopback'
        option 'ifname' 'lo'
        option 'proto' 'static'
        option 'ipaddr' '127.0.0.1'
        option 'netmask' '255.0.0.0'

config 'interface' 'lan'
        option 'type' 'bridge'
        option 'proto' 'static'
        option 'netmask' '255.255.255.0'
        option 'ifname' 'eth0.1'
        option 'ipaddr' '192.168.11.250'
        option 'defaultroute' '0'
        option 'peerdns' '0'

config 'interface' 'wan'
        option 'ifname' 'eth1'
        option 'proto' 'static'
        option 'netmask' '255.255.255.0'
        option 'gateway' '192.168.12.252'
        option 'dns' '192.168.12.252'
        option 'defaultroute' '0'
        option 'peerdns' '0'
        option 'ipaddr' '192.168.12.254'

config 'switch'
        option 'name' 'rtl8366s'
        option 'reset' '1'
        option 'enable_vlan' '1'
        option 'blinkrate' '2'

config 'switch_vlan'
        option 'device' 'rtl8366s'
        option 'vlan' '1'
        option 'ports' '0 1 2 5t'

config 'switch_port'
        option 'device' 'rtl8366s'
        option 'port' '1'
        option 'led' '6'

config 'switch_port'
        option 'device' 'rtl8366s'
        option 'port' '2'
        option 'led' '9'

config 'switch_port'
        option 'device' 'rtl8366s'
        option 'port' '5'
        option 'led' '2'

config 'switch_vlan'
        option 'ports' '3 5t'
        option 'vlan' '4'

config 'interface' 'wan2'
        option 'proto' 'static'
        option 'netmask' '255.255.255.0'
        option 'defaultroute' '0'
        option 'peerdns' '0'
        option 'macaddr' 'C0:3F:0E:78:3C:3C'
        option 'ifname' 'eth0.4'
        option 'ipaddr' '192.168.14.250'

/etc/config/firewall

config 'defaults'
        option 'syn_flood' '1'
        option 'input' 'ACCEPT'
        option 'output' 'ACCEPT'
        option 'forward' 'REJECT'

config 'zone'
        option 'name' 'lan'
        option 'input' 'ACCEPT'
        option 'output' 'ACCEPT'
        option 'forward' 'REJECT'
        option 'network' 'lan'

config 'zone'
        option 'name' 'wan'
        option 'input' 'REJECT'
        option 'output' 'ACCEPT'
        option 'forward' 'REJECT'
        option 'masq' '1'
        option 'mtu_fix' '1'
        option 'network' 'wan wan2'

config 'forwarding'
        option 'src' 'lan'
        option 'dest' 'wan'

config 'rule'
        option 'src' 'wan'
        option 'proto' 'udp'
        option 'dest_port' '68'
        option 'target' 'ACCEPT'
        option 'family' 'ipv4'

config 'rule'
        option 'src' 'wan'
        option 'proto' 'icmp'
        option 'icmp_type' 'echo-request'
        option 'target' 'ACCEPT'

config 'include'
        option 'path' '/etc/firewall.user'

config 'redirect'
        option 'src' 'wan'
        option 'src_dport' '222'
        option 'dest' 'lan'
        option 'dest_ip' '192.168.1.1'
        option 'dest_port' '22'
        option 'proto' 'tcp'

config 'rule'
        option 'src' 'wan'
        option 'dest_port' '22'
        option 'dest_ip' '192.168.1.1'
        option 'proto' 'tcp'
        option 'target' 'ACCEPT'

/etc/config/multiwan

config 'multiwan' 'config'
        option 'default_route' 'balancer'

config 'interface' 'wan'
        option 'weight' '10'
        option 'health_interval' '10'
        option 'timeout' '3'
        option 'health_fail_retries' '3'
        option 'health_recovery_retries' '5'
        option 'failover_to' 'wan2'
        option 'dns' 'auto'
        option 'icmp_hosts' 'gateway'

config 'interface' 'wan2'
        option 'weight' '5'
        option 'health_interval' '10'
        option 'timeout' '3'
        option 'health_fail_retries' '3'
        option 'health_recovery_retries' '5'
        option 'dns' 'auto'
        option 'icmp_hosts' 'gateway'
        option 'failover_to' 'wan'

/etc/config/fstab

config global automount
        option from_fstab 1
        option anon_mount 1

config global autoswap
        option from_fstab 1
        option anon_swap 0
config mount
        option target   /overlay
        option fstype   ext3
        option options  rw,sync
        option enabled_fsck 1
        option is_rootfs 1
        option uuid     '5cccd8bd-bd1e-4a26-9a3c-53f2ceeb134d'
        option enabled  1

#config mount
#       option target   /mnt/sda1
#       option device   /dev/sda1
#       option fstype   ext4
#       option options  rw,noatime
#       option enabled  0
#       option enabled_fsck 0

config swap
        option device   /dev/sda2
        option enabled  0

/etc/config/wireless

config 'wifi-device' 'radio0'
        option 'type' 'mac80211'
        option 'macaddr' 'c0:3f:0e:78:3c:3a'
        option 'hwmode' '11ng'
        list 'ht_capab' 'SHORT-GI-40'
        list 'ht_capab' 'TX-STBC'
        list 'ht_capab' 'RX-STBC1'
        list 'ht_capab' 'DSSS_CCK-40'
        option 'txpower' '0'
        option 'country' 'NL'
        option 'htmode' 'HT40-'
        option 'channel' '13'

config 'wifi-iface'
        option 'device' 'radio0'
        option 'mode' 'ap'
        option 'network' 'lan'
        option 'ssid' 'vs34-24'
        option 'encryption' 'psk2'
        option 'key' 'secret'

config 'wifi-device' 'radio1'
        option 'type' 'mac80211'
        option 'macaddr' 'c0:3f:0e:78:3c:3c'
        option 'hwmode' '11na'
        list 'ht_capab' 'SHORT-GI-40'
        list 'ht_capab' 'TX-STBC'
        list 'ht_capab' 'RX-STBC1'
        list 'ht_capab' 'DSSS_CCK-40'
        option 'country' 'NL'
        option 'channel' '48'
        option 'txpower' '17'
        option 'htmode' 'HT40-'

config 'wifi-iface'
        option 'device' 'radio1'
        option 'mode' 'ap'
        option 'network' 'lan'
        option 'ssid' 'vs34-50'
        option 'encryption' 'psk2'
        option 'key' 'secret'

Besides these issues I would like to thank you all for the good work.

Any help with this issue would me very much appreciated.

kind regards

Jouk Hettema

(Last edited by jouk on 6 Jan 2011, 09:28)

jouk wrote:

But when I configure and run multiwan the system spontaniously reboots! Configuration of my network is very standard (LAN/WAN/WAN2) as is the configuration of multiwan.

I have similar problem with a Linksys WRT54GL with Backfire (Two wan ADSL lines balanced with PPoE authentication under OpenWRT). The Linksys reboot unexpectedly, but this only happens the last 3 weeks (???). The multiwan version is 1.0.16.

Not sure but I think a hardware issue is the problem.

One week ago I migrate a Backfire 10.03.1-RC4/multiwan 1.0.19 on an Buffalo  WZR-HP-G300NH (much more memory and fast CPU). The problem disappear, but now the issue is similar to that posted by "Bad Joker". After a a wan fail does not reconnect when the ADSL line is up again. And I need manually restart multiwan.

Bad Joker wrote:

The failover does not work for me reliable on the 3g link. After a certain time it declares the connection as dead and disables it. But the modem is still connected (no disconnect in the syslog, the led of the usb dongle is still static on, so hwconnect is there). Also it does not try to do a reconnect. So useless in combination with 3g for me.

Hi!
I've successfully installed Multi-Wan on my TL-WR-1043ND but i still cannot force torrents to go only through wan2.
This is my multiwan config:

config 'multiwan' 'config'
        option 'default_route' 'wan'

config 'interface' 'wan'
        option 'weight' '10'
        option 'health_interval' '10'
        option 'timeout' '3'
        option 'health_fail_retries' '3'
        option 'health_recovery_retries' '5'
        option 'dns' 'auto'
        option 'icmp_hosts' 'disable'
        option 'failover_to' 'wan2'

config 'interface' 'wan2'
        option 'weight' '10'
        option 'health_interval' '10'
        option 'timeout' '3'
        option 'health_fail_retries' '3'
        option 'health_recovery_retries' '5'
        option 'failover_to' 'balancer'
        option 'dns' 'auto'
        option 'icmp_hosts' 'disable'

config 'mwanfw'
        option 'wanrule' 'wan'

config 'mwanfw'
        option 'proto' 'tcp'
        option 'ports' '51413'
        option 'wanrule' 'wan2'

but i still see that transmission still establishes torrent connections on first wan... any ideas?

Hello Chris
thanks for your great script. i'm using it on a ubiquity rs, running backfire-10.03.1-rc4. it works great with clients connected through a static route. but most of the clients in my setup are connected through a mesh network and the mesh routing is done by bmxd which uses routing tables 64/65 and rules 6400/6401, they seem to be deleted by the multiwan script :-(. maybe you'd like to join our discussion here?! 
http://lists.bmx6.net/pipermail/bmxd/20 … 00005.html
cheers

  --Jan

Can someone explain to me what is "option 'failover_to' 'balancer'"? What is the purpose of balancer here?

yeow wrote:

Can someone explain to me what is "option 'failover_to' 'balancer'"? What is the purpose of balancer here?

think of more than two wan connections

Does anyone else have a problem with the multiwan script picking up DNS entries for 3g modems?

multiwan doesn't seem to pick up my dns entries because it doesn't seem as though they propagate into the UCI database however they appear in /tmp/resolv.conf.ppp

anyone have ideas on how I can get DNS working for my cellular modems?

So the current 1.0.19 version support more that 2 WAN connections? Anyone has the complete configuration for that?

The current load balancing is based on round robin scheduler, or how it is done?

Working on a WRT160NL running Backfire (r24038) and 1.0.19-1. I believe my VLANs are setup correctly as the connections will work if only one of the sources are plugged in.  Both DIR-412 routers have aircards from the same network, could that be causing issues or does anyone have other ideas?

multiwan

config 'multiwan' 'config'
    option 'default_route' 'balancer'

config 'interface' 'wan'
    option 'weight' '10'
    option 'health_interval' '10'
    option 'icmp_hosts' 'dns'
    option 'timeout' '3'
    option 'health_fail_retries' '3'
    option 'health_recovery_retries' '5'
    option 'dns' 'auto'
    option 'failover_to' 'wan1'

config 'interface' 'wan1'
    option 'weight' '10'
    option 'health_interval' '10'
    option 'timeout' '3'
    option 'health_fail_retries' '3'
    option 'health_recovery_retries' '5'
    option 'failover_to' 'balancer'
    option 'dns' 'auto'
    option 'icmp_hosts' 'dns'

config 'mwanfw'
    option 'src' '192.168.1.0/24'
    option 'dst' 'ftp.netlab7.com'
    option 'proto' 'tcp'
    option 'ports' '21'
    option 'wanrule' 'lan'

config 'mwanfw'
    option 'src' '192.168.0.3'
    option 'proto' 'icmp'
    option 'wanrule' 'balancer'

config 'mwanfw'
    option 'dst' 'www.whatismyip.com'
    option 'wanrule' 'fastbalancer'

firewall

config 'defaults'
    option 'syn_flood' '1'
    option 'input' 'ACCEPT'
    option 'output' 'ACCEPT'
    option 'forward' 'REJECT'

config 'zone'
    option 'name' 'lan'
    option 'input' 'ACCEPT'
    option 'output' 'ACCEPT'
    option 'forward' 'REJECT'

config 'zone'
    option 'name' 'wan'
    option 'output' 'ACCEPT'
    option 'forward' 'REJECT'
    option 'masq' '1'
    option 'mtu_fix' '1'
    option 'input' 'ACCEPT'

config 'forwarding'
    option 'src' 'lan'
    option 'dest' 'wan1'

config 'rule'
    option 'src' 'wan'
    option 'proto' 'udp'
    option 'dest_port' '68'
    option 'target' 'ACCEPT'

config 'rule'
    option 'src' 'wan'
    option 'proto' 'icmp'
    option 'icmp_type' 'echo-request'
    option 'target' 'ACCEPT'

config 'include'
    option 'path' '/etc/firewall.user'

config 'zone'
    option 'name' 'wan1'
    option 'input' 'ACCEPT'
    option 'output' 'ACCEPT'
    option 'forward' 'REJECT'
    option 'masq' '1'
    option 'mtu_fix' '1'
    option 'network' 'wan1'

config 'forwarding'
    option 'src' 'lan'
    option 'dest' 'wan'

config 'forwarding'
    option 'src' 'lan'
    option 'dest' 'lan'

config 'rule'
    option 'target' 'ACCEPT'
    option 'src' 'wan1'
    option 'proto' 'udp'

config 'rule'
    option 'target' 'ACCEPT'
    option 'src' 'wan1'
    option 'proto' 'icmp'

network

config interface loopback
    option ifname    lo
    option proto    static
    option ipaddr    127.0.0.1
    option netmask    255.0.0.0

config interface lan
    option ifname    eth0.1
    option type    bridge
    option proto    static
    option ipaddr    192.168.1.1
    option netmask    255.255.255.0

config interface wan
    option ifname    eth1
    option proto    dhcp

config interface wan1
    option ifname    eth0.2
    option proto    dhcp

config switch rtl8306sd
    option name    eth0
    option reset    1
    option enable_vlan 1

config switch_vlan
    option device    eth0
    option vlan    1
    option ports    "1 2 3 4*"

config switch_vlan
    option device    eth0
    option vlan    2
    option ports    "0 4t"

(Last edited by cosmok on 30 Jan 2011, 02:34)

Got it working, if you're using two similar connection sources make sure they are different from eachother (192.168.2.1 and 192.168.1.1, both of mine were 192.168.0.1 and 192.168.0.2).  I had clients working off both so I had to finish this up once everyone got off both networks.  Thanks for the posts and the scripts.

(Last edited by cosmok on 30 Jan 2011, 14:20)

Is it possible to use something like "weighted fair queueing" to load-balance ?

I am trying to re-install multiwan but the luci app is offline. does anyone have it on a mirror somewhere? luci-app-multiwan

pio wrote:

I whipped up a thing allowing you to specify failover_to per wmanfw item in the config:

http://pio.longstair.com/misc/multiwan_ … .patch.txt

I emailed more details to SouthPawn.. if you are brave, give it a shot!

The change is incompatible with former version as failover_to is required:

multiwan_per_mwanfw_failover.patch.txt wrote:

+    if [ -z "$failover_to" -o -z "$wanrule" ]; then
+    return
+    fi

IMMO if failover_to is empty then use the same interface as wanrule to make it backwards compatible.

Where can I get the latest version?
The netlab ftp seems to be down, and I'm stuck with a very buggy 1.0.16 version.