OpenWrt Forum Archive

Topic: mwan3; multi-wan policy routing (general topic)

The content of this topic has been archived between 22 May 2013 and 6 May 2018. Unfortunately there are posts – most likely complete pages – missing.

thdyck wrote:

1. Does a load-balanced connection also provide failover automatically to the remaining link if one of the links goes down? The load-balancing metric is ignored if one of the links is down so as to send 100% of traffic through the remaining working link?

Yes

thdyck wrote:

2. For load-balancing, the selection of outgoing interface is made by the Linux kernel at the time of the start of the IP connection based on destination IP address? So, all connections to the same specific destination IP address will go through the same WAN interface? How is UDP handled where there is no connection state?

The linux kernel uses some kind of fake connection state. When an udp packet leaves the router it's stored in the session table as NEW. When a returning packet is seen, it's marked ESTABLISHED. It's not really a three-way session, but this is how it's tracked.

pingo wrote:

I have one problem though, I cannot get traffic over both wifi interfaces at the same time.

...

Can anyone look at my setup and tell me if there is a mistake in it? Otherwise, does anyone have any clue why this would be happening and how I could debug it?

Your config looks fine to me. Could you please try it with the option equalize set to "1".

ranfish wrote:

1.Lower cpu consumption.One my wdr7500 with two wans (100mbit+24mbit),mwan3 eats a lot cpu.

Unless there is some other way of "cheaply" analyzing all the individual packets, i don't think that will be possible. I myself would also be very interested.

Just curious: What is the CPU load when mwan3 is not used?

ranfish wrote:

2.Allow custom route table for some specific ip sections

I think it's a great idea to introduce ip ranges. I will see what i can do, allthough the examples you posted are easily aggregatable.

(Last edited by Adze on 19 Aug 2013, 00:23)

headless.cross wrote:

@pingo:

How strong is the wifi signal between you and those two APs? I'm asking that because I have similar setup and the wifi signal affects the load-balancing.


Adze wrote:
pingo wrote:

I have one problem though, I cannot get traffic over both wifi interfaces at the same time.

...

Can anyone look at my setup and tell me if there is a mistake in it? Otherwise, does anyone have any clue why this would be happening and how I could debug it?

Your config looks fine to me. Could you please try it with the option equalize set to "1".


It turned out headless.cross was onto something as I changed one wifi from channel 13 to channel 6 and now both wifis load balance fine. So thanks for the help and sorry since the problem was not mwan3 related.

I can now report that mwan3 works great load-balancig an ethernet wan and 2 wifi wans smile

Hello,

Congratulations to All who contributed to this wonderful project!
I installed and configured mwan3 on TP-Link TL-WR740N running OpenWrt Attitude Adjustment 12.09. I configured two WAN interfaces, both using DHCP.
However, when the primary WAN interface (the physical WAN port) goes down, the router won't resolve hostnames.
I noticed the resolve is done with the loopback IP address (127.0.0.1). I thought this would cause the problem and created manually a new /etc/resolv.conf file containing the four DNS servers' addresses I'm using (two for each ISP). The router now tries to resolve via the first of them, but still unsuccessfully when the primary WAN is down. Resolving with Google's public DNS (8.8.8.8) also isn't successful.
If using nslookup on a PC behind the router and specifying which DNS server to look up, the result is correct. I looked at /tmp/resolv.conf.auto while the primary WAN is down and the list is correct, but still includes all 4 DNS servers.
I tried "rerouting" the traffic, originating from the WAN (interface WAN1 config in mwan3), but with no success.
Am I missing something trivial? If not, I'm posting mwan3 and network configurations at the bottom of my post. If there are any additional configs needed, please, inform me. Otherwise, I'd really appreciate it if someone more experienced could look at them.
This problem leads to inability to open any webpage that hasn't been resolved yet and having its IP address cached. Doing nslookup on a PC and then entering the IP address in a browser launches the page successfully. Otherwise, traffic seems to be failing over and failing-back properly.

And a final question: there would be no issues, if both interfaces had the same weight set, would be?

root@OpenWrt:~# cat /etc/config/network 


# This is a mwan3 example config. For mwan3 to work you will need at least:
#
# - 2 interfaces
# - 2 members
# - 1 policy
# - 1 rule
#
# First define all your wan interfaces. Interface name must match with the
# name used in your network configuration:

config 'interface' 'wan'
    option 'enabled' '1'
    list 'track_ip' '8.8.4.4'
    list 'track_ip' '8.8.8.8'
    list 'track_ip' '46.40.72.17'
    list 'track_ip' '46.40.72.18'
    option 'reliability' '2'
    option 'count' '1'
    option 'timeout' '2'
    option 'interval' '5'
    option 'down' '3'
    option 'up' '8'
    option 'reroute' '0'

config 'interface' 'wan2'
    option 'enabled' '1'
    list 'track_ip' '8.8.8.8'
    list 'track_ip' '217.9.239.90'
    list 'track_ip' '217.9.239.94'
    option 'reliability' '1'
    option 'count' '1'
    option 'timeout' '2'
    option 'interval' '5'
    option 'down' '3'
    option 'up' '8'
    option 'reroute' '0'

# Next define a member and configure metric and weight values for this member.
# Each interface can have multiple member definitions. Give each member a correct
# name (A-Z, a-z, 0-9, "_" and no spaces).

config 'member' 'wan1_m1_w3'
    option 'interface' 'wan'
    option 'metric' '1'
    option 'weight' '3'

config 'member' 'wan1_m2_w3'
    option 'interface' 'wan'
    option 'metric' '2'
    option 'weight' '3'

config 'member' 'wan2_m1_w2'
    option 'interface' 'wan2'
    option 'metric' '1'
    option 'weight' '2'

config 'member' 'wan2_m2_w2'
    option 'interface' 'wan2'
    option 'metric' '2'
    option 'weight' '2'

# After that create a routing policy. A routing policy consist of one or more
# members. Give each policy a correct name (A-Z, a-z, 0-9, "_" and no spaces). You 
# can create multiple policies, so that it is possible for different traffic to
# have different primary and/or backup interfaces.

config 'policy' 'wan1_only'
    list 'use_member' 'wan1_m1_w3'

config 'policy' 'wan2_only'
    list 'use_member' 'wan2_m1_w2'

config 'policy' 'wan1_wan2_loadbalanced'
    list 'use_member' 'wan1_m1_w3'
    list 'use_member' 'wan2_m1_w2'

config 'policy' 'wan1_pri_wan2_sec'
    list 'use_member' 'wan1_m1_w3'
    list 'use_member' 'wan2_m2_w2'

config 'policy' 'wan2_pri_wan1_sec'
    list 'use_member' 'wan1_m2_w3'
    list 'use_member' 'wan2_m1_w2'

# And to finish the config define your traffic rules. Rules are matched in top to
# bottom order. If you define a rule and it matches, all following rules are ignored.
#
# If the option equalize is set, mwan3 will load-balance each new session to the same
# host. If not set, it will load-balance based on destination.

#config 'rule' 'rule1'
#    option 'src_ip' '192.168.21.0/24'
#    option 'proto' 'tcp'
#    option 'dest_port' '563'
#    option 'use_policy' 'wan2_only'

#config 'rule' 'rule2'
#    option 'src_ip' '192.168.21.0/24'
#    option 'proto' 'tcp'
#    option 'dest_port' '995'
#    option 'use_policy' 'wan1_only'
#
#config 'rule' 'rule3'
#    option 'dest_ip' '88.154.0.0/16'
#    option 'proto' 'tcp'
#    option 'dest_port' '1024:65535'
#    option 'equalize' '1'
#    option 'use_policy' 'wan1_wan2_loadbalanced'
#
#config 'rule' 'rule4'
#    option 'dest_ip' '77.11.41.0/24'
#    option 'proto' 'tcp'
#    option 'dest_port' '1024:65535'
#    option 'use_policy' 'wan1_pri_wan2_sec'
#
#config 'rule' 'rule5'
#    option 'dest_ip' '112.136.0.0/16'
#    option 'proto' 'udp'
#    option 'dest_port' '5352'
#    option 'use_policy' 'wan2_pri_wan1_sec'
#
config 'rule' 'rule6'
    option 'dest_ip' '0.0.0.0/0'
    option 'use_policy' 'wan1_wan2_loadbalanced'
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'
    option macaddr '00:21:91:EA:D7:12'
    option metric '10'

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

config switch_vlan
    option device 'eth0'
    option vlan '1'
    option vid '1'
    option ports '0t 1 3 4'

config switch_vlan
    option device 'eth0'
    option vlan '2'
    option ports '0t 2'
    option vid '3'

config interface 'wan2'
    option proto 'dhcp'
    option ifname 'eth0.3'
    option metric '20'

Thank You in advance,
Nickolay

n_dandanov wrote:

If using nslookup on a PC behind the router and specifying which DNS server to look up, the result is correct.
...
And a final question: there would be no issues, if both interfaces had the same weight set, would be?

Hi Nickolay,

It is a big clue that traffic from behind the router is working fine.

I see you have reroute set to 0 (disabled) on your WAN interfaces. If the "reroute" option is disabled, traffic from the router itself will not follow mwan3 failover rules. This traffic will use the router's default routing table and so not go out when the wan interface is down.

Can you set the following option for both your WAN interfaces and try again?

option 'reroute' '1'

It's fine to give both WAN interfaces the same weight. If so, traffic will be load-balanced evenly between them.

Regards,
Tim

Hello, thdyck,

Thank You a lot for the advice! I had set reroute on WAN 1 only but it didn't seem to work. Now I set it to both interfaces, and also set equal weights (3) to WAN1 and WAN2. Then rebooted the router and the resolves now seem to be working flawlessly. I get them from the loopback interface on the router without specifying which DNS server to look up in. Resolves are correct also on a PC behind the router so web browsing now seems to be working nicely.

Thank You a lot for the great software and support! If I can assist You with anything, I'd be glad to.

Best regards,
Nickolay

Dear All,

I spotted similar problem to the one I mentioned in my last posts. This time the router wouldn't resolve hostnames after a fail-back. At the time present I have all four DNS servers set manually in a file and dhcp configuration (dnsmasq) pointed to look in this file.
As some other fellow members, I also thought it would be nice to have a kind of reporting the mwan3 log when there is a new event. I tried doing this using an e-mail client (in my case, msmtp). However this failed, as my router (TP-Link TL-WR740n) doesn't have enough free flash storage to install libopenssl. This library seems to be used for SSL authentication when sending e-mails and therefore is needed along with msmtp.
I ended up installing msmtp-nossl. The install went trouble-free, but afterwards I failed to find a free no-ssl mail server which would accept the no-ssl e-mails I was sending from the router. I know Google has a way of relaying such messages, but I didn't delve further and decided the research wasn't worth it at this time.
I came up with a slightly different concept:

1. Look in the system log on a defined interval;
2. Check whether there is an update related to mwan3;
3. If yes, copy the log contents which are relevant to mwan3. Then upload this log to a ftp server;
4. If not, do nothing.

I implemented this using the directory /usr/share/reporter/ ('reporter' here is the name I chose both for the folder and for the short script which would do the steps outlined above). For ftp server I'm currently using the free service from DriveHQ. For uploading there I chose the package wput, so You'll need to install it if You'd use the script quoted here.

Here's the script itself. It's name is reporter.sh:
root@OpenWrt:~# cat /usr/share/reporter/reporter.sh

#!/bin/ash

unset news
unset olds

#Checking the logs for new events, related to mwan3:
logread | grep mwan3 > /usr/share/reporter/readlogtmp
news=$(tail -n 1 /usr/share/reporter/readlogtmp)
olds=$(tail -n 1 /usr/share/reporter/readlog)

#If there are new events:
if [ "$olds" != "$news" ]
then

#Constructing the log file:
date > /usr/share/reporter/readlog
uptime >> /usr/share/reporter/readlog
echo -e  "\n\nLog below:\n\n" >> /usr/share/reporter/readlog
logread | grep mwan3 >> /usr/share/reporter/readlog

#Uploading the file with current timestamp:
unset filename
unset now
now=$(date +"%Y-%m-%d-%H-%M" )
filename="readlog_$now.txt"
wput /usr/share/reporter/readlog ftp://XXXXX:YYYYY@ftp.drivehq.com/Router_logs/mwan3/"$filename"
unset filename
unset nowYYYYY
fi

#Removing the temporary file and variables:
rm -f /usr/share/reporter/readlogtmp
unset news
unset olds

Replace XXXXX with Your username and YYYYY with Your password for the ftp server.

As You can see, it's basically storing the mwan3 log in a file called readlog.
In order to accomplish this, the script is making a new temporary file named readlogtmp in which it copies the current system log related to mwan3. This is done using "logread | grep mwan3".
Then in two string variables - news and olds, it's copying the last lines of the logs stored in readlog and readlogtmp. If there's no readlog file, the tail command gives an error, but the script goes on and creates such file with the current mwan3 log contents.
Afterwards we're comparing news and olds. If they match, we do nothing but release the used variables and remove the temporary file.
If they don't, we create the readlog file with the actual timestamp, uptime and mwan3 logs. The file has a similar construction:

Sat Aug 24 17:40:01 EEST 2013
17:40:01 up 14 min,  load average: 0.02, 0.06, 0.06


Log below:


Aug 24 17:25:13 OpenWrt user.info mwan3: ifup interface wan2 (eth0.3)
Aug 24 17:25:19 OpenWrt user.info mwan3: ifup interface wan (eth1)
Aug 24 17:25:31 OpenWrt user.info mwan3track: Lost 4 ping(s) on interface wan (eth1)
Aug 24 17:25:40 OpenWrt user.info mwan3: ifup interface wan (eth1)
Aug 24 17:26:37 OpenWrt user.info mwan3: ifup interface wan2 (eth0.3)
Aug 24 17:33:45 OpenWrt user.info mwan3track: Interface wan (eth1) is offline
Aug 24 17:33:46 OpenWrt user.info mwan3: ifdown interface wan (eth1)
Aug 24 17:35:38 OpenWrt user.info mwan3track: Lost 44 ping(s) on interface wan (eth1)
Aug 24 17:36:14 OpenWrt user.info mwan3track: Interface wan (eth1) is online
Aug 24 17:36:16 OpenWrt user.info mwan3: ifup interface wan (eth1)

(This one contains the information recorded after a router reboot and wan interface going down, then up).
The file uploaded to the ftp server has a similar name:

readlog_2013-08-24-17-40.txt

This way its contents can be viewed directly in DriveHQ's website. These files are uploaded to a folder /Router_logs/mwan3/ on the server.
At the end of the script we are removing the temporary file and the used variables.

After the script is in place, we need to schedule it's execution at a give interval of time. I chose 5 minutes, as this seems reasonable to me. Feel free to correct me if I'm wrong.
For the purpose I entered a crontab entry. Here's how it looks currently:

root@OpenWrt:~# crontab -l
*/5 * * * * /usr/share/reporter/reporter.sh

The */5 indicates the desired interval. (You might want to check wiki). After I made sure the script was being executed properly and working good, I edited the cron file in /etc/init.d so that crontab wouldn't log in the system log. Here's how it looks now:

root@OpenWrt:~# cat /etc/init.d/cron

#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org

START=50

SERVICE_USE_PID=1

start () {
    loglevel=$(uci_get "system.@system[0].cronloglevel")
    [ -z "$(ls /etc/crontabs/)" ] && exit 1
    mkdir -p /var/spool/cron
    ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null
#    Some changes in order NOT to log to syslog. Below is the original line:
#    service_start /usr/sbin/crond -c /etc/crontabs -l ${loglevel:-5}
#    And here is the new line:
    service_start /usr/sbin/crond -c /etc/crontabs -L /dev/null
}

stop() {
    service_stop /usr/sbin/crond
}

(Here very helpful was this).

That's the setup I have at the moment and it seems to be working as expected. I'd be very grateful to hear Your comments and advices. Please, note that I don't have much experience with Linux and OpenWrt so there may be wrongly used manners in the script I posted.

Best regards,
Nickolay

Just a small note on dns and mwan3. If you use the dns servers from your isp, it is very common that resolving fails if you try it with a wan interface (source ip address) that is not from that specific provider. I recommend to use opendns or google's dns service as they work from any ip address. It is not an mwan3 issue.

Hi Adze,

My questions might look very silly to you but please very badly m looking for the answer.

I'm not clear with mutiwan concept and testcase, can you please provide me any document related to this.

what is the diffrence between mwan3 and luci-mutilwan ?


And also i have taken mwan3 package compiled with latest openwrt trunk and booted the image.now i will tell you what all steps i have followed :

1. created two wan connection nas0,nas1 in dhcp mode with successfull configuration.i.e i conformed by executing below command.

ping -c 1 -I nas0 www.google.com
ping -c 1 -I nas0 www.google.com

both case ping was successful.

root@OpenWrt:/# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         200.200.59.1    0.0.0.0         UG    10     0        0 nas0
0.0.0.0         200.200.60.1    0.0.0.0         UG    20     0        0 nas1
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 br-lan
200.200.59.0    0.0.0.0         255.255.255.0   U     0      0        0 nas0
200.200.60.0    0.0.0.0         255.255.255.0   U     0      0        0 nas1

2.then configured mwan3 config file

config 'interface' 'wan1'
        option 'enabled' '1'
        list 'track_ip' '8.8.4.4'
        list 'track_ip' '8.8.8.8'
        list 'track_ip' '200.200.59.1'
        list 'track_ip' '208.67.220.100'
        option 'reliability' '2'
        option 'count' '1'
        option 'timeout' '2'
        option 'interval' '5'
        option 'down' '3'
        option 'up' '8'
        option 'reroute' '0'

config 'interface' 'wan2'
        option 'enabled' '1'
        list 'track_ip' '8.8.8.8'
        list 'track_ip' '200.200.60.1'
        list 'track_ip' '200.200.60.100'
        option 'reliability' '1'
        option 'count' '1'
        option 'timeout' '2'
        option 'interval' '5'
        option 'down' '3'
        option 'up' '8'
        option 'reroute' '0'

# Next define a member and configure metric and weight values for this member.
# Each interface can have multiple member definitions. Give each member a correct
# name (A-Z, a-z, 0-9, "_" and no spaces).

config 'member' 'wan1_m1_w3'
        option 'interface' 'wan1'
        option 'metric' '1'
        option 'weight' '3'

config 'member' 'wan1_m2_w3'
        option 'interface' 'wan1'
        option 'metric' '2'
        option 'weight' '3'

config 'member' 'wan2_m1_w2'
        option 'interface' 'wan2'
        option 'metric' '1'
        option 'weight' '2'

config 'member' 'wan2_m2_w2'
        option 'interface' 'wan2'
        option 'metric' '2'
        option 'weight' '2'

# After that create a routing policy. A routing policy consist of one or more
# members. Give each policy a correct name (A-Z, a-z, 0-9, "_" and no spaces). You
# can create multiple policies, so that it is possible for different traffic to
# have different primary and/or backup interfaces.

config 'policy' 'wan1_only'
        list 'use_member' 'wan1_m1_w3'

config 'policy' 'wan2_only'
        list 'use_member' 'wan2_m1_w2'

config 'policy' 'wan1_wan2_loadbalanced'
        list 'use_member' 'wan1_m1_w3'
        list 'use_member' 'wan2_m1_w2'

config 'policy' 'wan1_pri_wan2_sec'
        list 'use_member' 'wan1_m1_w3'
        list 'use_member' 'wan2_m2_w2'

config 'policy' 'wan2_pri_wan1_sec'
        list 'use_member' 'wan1_m2_w3'
        list 'use_member' 'wan2_m1_w2'

# And to finish the config define your traffic rules. Rules are matched in top to
# bottom order. If you define a rule and it matches, all following rules are ignored.
#
# If the option equalize is set, mwan3 will load-balance each new session to the same
# host. If not set, it will load-balance based on destination.

config 'rule' 'rule1'
        option 'src_ip' '192.168.1.0/24'
        option 'proto' 'tcp'
        option 'dest_port' '563'
        option 'use_policy' 'wan2_only'

config 'rule' 'rule2'
        option 'src_ip' '192.168.1.0/24'
        option 'proto' 'tcp'
        option 'dest_port' '995'
        option 'use_policy' 'wan1_only'

config 'rule' 'rule3'
        option 'dest_ip' '200.200.0.0/16'
        option 'proto' 'tcp'
        option 'dest_port' '1024:65535'
        option 'equalize' '1'
        option 'use_policy' 'wan1_wan2_loadbalanced'

config 'rule' 'rule4'
        option 'dest_ip' '200.200.59.0/24'
        option 'proto' 'tcp'
        option 'dest_port' '1024:65535'
        option 'use_policy' 'wan1_pri_wan2_sec'

config 'rule' 'rule5'
        option 'dest_ip' '200.200.60.0/16'
        option 'proto' 'udp'
        option 'dest_port' '5352'
        option 'use_policy' 'wan2_pri_wan1_sec'

config 'rule' 'rule6'
        option 'dest_ip' '0.0.0.0/0'
        option 'use_policy' 'wan1_wan2_loadbalanced'

3. my network config files as below:

root@OpenWrt:/# cat /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 globals 'globals'
        option ula_prefix 'fd9e:8265:7b25::/48'

config interface 'lan'
        option ifname 'eth0'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

config atm-bridge 'atm'
        option vci '32'
        option encaps 'llc'
        option payload 'bridged'
        option vpi '0'

config interface 'wan6'
        option ifname '@wan'
        option proto 'dhcpv6'

config interface 'wan1'
        option ifname 'nas0'
        option _orig_ifname 'nas0'
        option _orig_bridge 'false'
        option proto 'dhcp'
        option metric '10'

config atm-bridge
        option unit '0'
        option atmdev '0'
        option encaps 'llc'
        option payload 'bridged'
        option vci '35'
        option vpi '0'

config interface 'wan2'
        option proto 'dhcp'
        option ifname 'nas1'
        option metric '20'

4. firewall config

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 'ACCEPT'
        option network 'lan'

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


5. now rebooted the board and it comes up without any issue. nas0, nas1 got ip and i can see some TX,RX pkts in both the interfaces.

6. now what should be the test case to conform that mwan3 working or not working.

I didn't look at your config much so perhaps some of these tests don't apply to your configuration but here are a few lame suggestions on what you can test:
- Start a high speet torrent download and then use

bmon -p 'nas*'

to monitor bandwidth on both interfaces
- Go to a website that reports your ip address (google "whatismyipaddress") and keep refreshing to see if the ip is changing
- Try unplugging/disabling one of the two interfaces and see what happens

Ramesh_P wrote:

what is the diffrence between mwan3 and luci-mutilwan ?

From my understanding you have 2 solutions that try to serve a similar purpose:
There is multiwan + luci-app-multiwan
and mwan3 + luci-app-mwan3

The luci packages just add a web interface so that you can configure everything through it instead editing config files.

One difference I've noticed between multiwan and mwan3 is that mwan3 appears to work fine with overlapping subnets on wan interfaces while multiwan does not.

Hi pingo,

thanks for your quick reply.

Hi all
I'm trying to use mwan3 to failover from ADSL to 3G/UMTS connectivity but I would like to have 3G/UMTS connectivity interface up only when ADSL connection is down. I tried to change the /etc/hotplug.d/iface/16-mwan3custom script like this

case "$ACTION" in
        ifup)
if ["$INTERFACE" = "WAN"]
                report_event
                ifdown WAN3G
fi
        ;;

        ifdown)
if ["$INTERFACE" = "WAN"]
                report_event
                ifup WAN3G
fi
        ;;
esac

but it doesn't work. Plus, I'm not convinced that this would run also in case ADSL provider has problems but physically interface WAN is still up.

Any hint?

Thanks a lot
Riccardo

Hi rickyc,


Maybe you could try the following code.

case "$ACTION" in
   ifup)
      if ["$INTERFACE" == "WAN"]
         report_event
         ifdown WAN3G &
      fi
   ;;
   ifdown)
      if ["$INTERFACE" == "WAN"]
         report_event
         ifup WAN3G &
      fi
   ;;
esac

I think the problem is the following. Your code spawns another hotplug event. The new process will wait until the current has ended, but it will never end because the current is still waiting for the new one to finish...

And this will also work if your isp has troubles, but the wan link remains up. Use some track_ip host in your mwan3 config for your main wan connection.

(Last edited by Adze on 8 Sep 2013, 21:02)

Hi,

First of all .. thanks for this nice funcionality.

I have mwan3 set up with adsl and 3g/umts for a failover scenario*),
but am a little bit puzzled with test results.

Could someone verify outcome of tests/mwan3 behaviour please ...

I used two tests issued from another computer:
1) traceroute -m 3 8.8.8.8
2) ping 8.8.8.8

I ran test 1) with adsl/3g functioning and indeed it took route via adsl.
Next I unplugged the wan/adsl cable from router and yes it went via 3g
I plugged in the wan/adsl cable again and -huray!- adsl route again.
So far so good ....

Now I do test 2) with adsl/3g functioning and ideed it took route via adsl
Next I unplugged the wan/adsl cable from router and yes it went via 3g
I plugged in the wan/adsl cable again and to my surprise traffic still went via 3g

Is this normal when testing with ping, ie should I not use this test?

Regards,
Ferry

*)

config rule 'rule6'
    option dest_ip '0.0.0.0/0'
    option use_policy 'wan1_pri_wan2_sec'

fharmusial wrote:

Is this normal when testing with ping, ie should I not use this test?

Ping is suitable for testing. As long as it is matched in the rules.

I cant tell you why test2 failed. I dont have enough info to determine what went wrong or what you did or how long you waited. You haven't posted your config. With al these uncertainties it is impossible to answer your question.

Adze wrote:

I dont have enough info to determine what went wrong or what you did or how long you waited.

Hi Adze,

Thank you for your swift reply.
I will first do my homework (ie Ialready spotted incosistency in my config)
and if needed I just might try again on this thread.

Regards,
Ferry

Adze wrote:

Hi rickyc,


Maybe you could try the following code.

case "$ACTION" in
   ifup)
      if ["$INTERFACE" == "WAN"]
         report_event
         ifdown WAN3G &
      fi
   ;;
   ifdown)
      if ["$INTERFACE" == "WAN"]
         report_event
         ifup WAN3G &
      fi
   ;;
esac

I think the problem is the following. Your code spawns another hotplug event. The new process will wait until the current has ended, but it will never end because the current is still waiting for the new one to finish...

And this will also work if your isp has troubles, but the wan link remains up. Use some track_ip host in your mwan3 config for your main wan connection.

Hi,
thanks a lot for your help. I tried but I get this error

Sep  9 20:13:22 OpenWrt user.info sysinit: /sbin/hotplug-call: /etc/hotplug.d/iface/16-mwan3custom: line 123: [wan: not found

and strange enough line 123 is the line with "esac", as below

case "$ACTION" in
        ifup)
                if ["$INTERFACE" == "wan"];
                then
                report_event
                ifdown WAN3G &
fi
        ;;

        ifdown)
if ["$INTERFACE" == "wan"];
then
                report_event
                ifup WAN3G &
fi
        ;;
esac

exit 0

where I also tried adding ";" at the end of the "if" lines..

Any idea of what I am still doing wrong?

Thanks!
Riccardo

Hi rickyc,


The following code works for me:

#!/bin/sh

case "$ACTION" in
   ifup)
      if [ "$INTERFACE" == "wan1" ]; then
         logger -t mwan3 "Interface wan1 came up, tearing down interface wan2"
         ifdown wan2 &
      fi
   ;;
   ifdown)
      if [ "$INTERFACE" == "wan1" ]; then
         logger -t mwan3 "Interface wan1 went down, bringing up interface wan2"
         ifup wan2 &
      fi
   ;;
esac

exit 0

I forgot to mind the space between "[" and "$INTERFACE".

(Last edited by Adze on 9 Sep 2013, 20:29)

Adze wrote:

I forgot to mind the space between "[" and "$INTERFACE".

Hi Adze,
this was the problem! :-) Thanks!

Now, I don't get any error but it seems that the IF is not triggered. I tried

if [ "$INTERFACE" == "WAN"];

both with "WAN" (name in Network->Interfaces), with "wan" (name in MWAN3->Interfaces) and also with eth0.2 (physical name). Which name should I use?

Since we are at it, is there a command to introduce a pause in the script for a few seconds? I need to wait until 3G interface is down before sending an SMS with gnokii...

Thanks again!!
Riccardo

rickyc wrote:

Now, I don't get any error but it seems that the IF is not triggered. I tried

if [ "$INTERFACE" == "WAN"];

You also need a space between "WAN" and "]".

rickyc wrote:

both with "WAN" (name in Network->Interfaces), with "wan" (name in MWAN3->Interfaces) and also with eth0.2 (physical name). Which name should I use?

The name of the interface should be the same in /etc/config/network and /etc/config/mwan3. Else it won't work!. You need that name.

rickyc wrote:

Since we are at it, is there a command to introduce a pause in the script for a few seconds? I need to wait until 3G interface is down before sending an SMS with gnokii...

sleep 10 #to wait ten seconds
Adze wrote:

You also need a space between "WAN" and "]".

Thanks a lot, it works!!!! :-)

Best regards
Riccardo

Hi Adze,

please help me to understand, for me mwan3 is not working.

i have created two wan connection nas1 and nas3 on dhcp mode , got the ip and tried to ping google.

root@openwrt:~# ping -c 1 -I nas1 www.google.com
root@openwrt:~# ping -c 1 -I nas3 www.google.com

ping successful.

now i did mwan3 config changes and firewall  config changes as mentioned by you. then rebooted the board, after reboot m not able to ping to google with same command as above.

root@OpenWrt:/# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         200.209.62.1    0.0.0.0         UG    10     0        0 nas1
0.0.0.0         200.209.64.1    0.0.0.0         UG    20     0        0 nas3
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 br-lan
200.209.62.0    0.0.0.0         255.255.255.0   U     10     0        0 nas1
200.209.64.0    0.0.0.0         255.255.255.0   U     20     0        0 nas3

root@OpenWrt:/# ping -c 1 -I nas1 www.google.com
ping: bad address 'www.google.com'       --> dns resolution is not happing

and i dont find any files uner /tmp directory related dns resolve.


ip rule show command also shows very diffrent result from what you have mentioned.

root@OpenWrt:/# ip rule show
0:      from all lookup local
9:      from all fwmark 0x1 lookup LoadBalancer
32766:  from all lookup main
32767:  from all lookup default


root@OpenWrt:/# iptables -L mwan3_pre -t mangle -v -n
iptables: No chain/target/match by that name.

root@OpenWrt:/# iptables -L mwan3_post -t mangle -v -n
iptables: No chain/target/match by that name.

root@CDR6-U11-10:~#  iptables -L mwan3_default -t mangle -v -n
iptables: No chain/target/match by that name

root@OpenWrt:/# iptables -L mwan3_rules -t mangle -v -n
iptables: No chain/target/match by that name.

Looks like mwan3 not configured during bootup and tried start manually after reboot but i got following error.

root@OpenWrt:/# ACTION=ifup DEVICE=nas1 INTERFACE=wan1 /sbin/hotplug-call iface
uci: Parse error (unterminated ') at line 15, byte 32
sh: 1: unknown operand

root@OpenWrt:/# /etc/init.d/mwan3 start
uci: Parse error (unterminated ') at line 15, byte 32
sh: 1: unknown operand
uci: Parse error (unterminated ') at line 15, byte 32
sh: 1: unknown operand

can you please tell me what colud be the issue here to fail to start mwan3.

Is wan connection needs to be created under eth0.x interface ?
Is there problem with nas interface ?

thanks in advance .

Hi Ramesh_P,


I have never seen that error (uci: Parse error (unterminated ') at line 15, byte 32) before. Don't know what is causing this.

What strikes me is when you issue the command "ip rule show", that there is a line "9 from all fwmark 0x1 lookup LoadBalancer". Mwan3 does not add this rule. Have you installed some other load-balancing software, like multiwan? What version of mwan3 are you running? How did you install it? Looks like a corrupt version of some kind...

Hi Adze,

thanks for quick reply,

cloned source from : git clone https://github.com/Adze1502/mwan .
version : this is wat makefile shows.
PKG_NAME:=mwan3
PKG_VERSION:=1.2
PKG_RELEASE:=18

And your correct openWRT multwan also enabled, let me try by disabling multwan.


Second part of the question wasnt answerd. is there any restriction to create type wan connection?
    - like it should be eth0.x not nas or pppoe interfaces.

(Last edited by Ramesh_P on 10 Sep 2013, 15:22)