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.

Sorry my fault, i didn't realize that mediafire is not something with one-time links smile

Maybe you could add the mediafire URL to the first post and remove the old URL?

(Last edited by Thomymaster on 29 May 2013, 07:54)

Sorry, posts 302 to 300 are missing from our archive.

Didn't arfett just release the latest binary 1-2 days ago?

Thomymaster wrote:

Maybe you could add the mediafire URL to the first post and remove the old URL?

Done

I still want to have email message when my link goes from ppoe-wan to 3g-wwan and vice versa. Earlier in this script i was given the following snippet:

#!/bin/sh

# place in /etc/hotplug.d/iface and name 19-mymwancustom
# make executable with 'chmod +x 19-mymwancustom'
#
# available variables:
# $ACTION is the hotplug event
# $INTERFACE is the interface name (wan1, wan2, etc.)
# $DEVICE the device name attached to the interface (eth0.1, eth1, etc.)

case "$ACTION" in
    ifup)
        # run this code or additional function added to this script
        # if any interface comes online

        # if you want to limit it to certain interfaces you can do
        #if [ "$INTERFACE" == "wan1" ]; then
            # run this code
        #fi
    ;;

    ifdown)
        # run this code or additional function added to this script
        # if any interface goes offline
    ;;
esac

I don't understand this, i think both interfaces are always up? Please help me, i only wand a single mail like

"Internet connection swapped from ppoe-wan to 3g-wwan"

and

"Internet connection swapped from 3g-wwan to ppoe-wan"

As mentioned earlier in this post it would be really great to have a luci-web-page just defining which custom shell scripts can be run in case of these events smile

If you track the interfaces then the mwan3track scripts send ifup/ifdown hotplug events. Put your code/scripts in those sections or add your own hotplug script.

headless.cross wrote:
khanh3t wrote:

hi Adze

I dont know why. I load balancing 2 line 3G. After 5 minutes download, 1 line will not load balancing. Only 1 line download, i remove line working, line remain work ( that is no line drop ). I think maybe my usb hub, but i change other hub ( 2 kind, and many hub ) nothing change.
/ps: i cant remove ip server ping in interface

I'm experiencing the same behaviour. After a while, the traffic flows through one interface and the load-balancing fades away.
Stopping the download procces fixes things, e.g. my external IP changes correctly.

I think this is caused by bad pings. I had the same problem. Until yesterday I was using an old WRT54GL as repeater, and during a heavy load (many connections on a torrent) the pings from 50ms were jumpin to 5000ms or something like that. A friend of mine gave me his TL-WN722N, which replaced the WRT54GL and ... voila!

Everything now is fine, the download speed is blazing fast and everyone is happy!

khanh3t

Can you try setting your ping timeout to 5 seconds and see what happens?

Also if you download the latest mwan3 LuCI app 1.0-12 from the mediafire link there's more options on the GUI now for up to 10 second timeouts.

(Last edited by arfett on 31 May 2013, 11:51)

@arfett:

I just downloaded the latest binaries from mediafire, but I had errors during installation "deb invalid magic". IMHO you have to run "make clean" and then re-compile the packages.

headless.cross wrote:

@arfett:

I just downloaded the latest binaries from mediafire, but I had errors during installation "deb invalid magic". IMHO you have to run "make clean" and then re-compile the packages.

My script does that every time I compile. Worked for me.

(Last edited by arfett on 31 May 2013, 13:15)

arfett wrote:

My script does that every time I compile.

Strange though, I had to compile the sources by myself and then the installation went fine.

Thomymaster wrote:

As mentioned earlier in this post it would be really great to have a luci-web-page just defining which custom shell scripts can be run in case of these events smile

Not going to happen anytime soon. Because of how the rules/policies work it would be rather difficult (giant pain in the balls) for Adze to add any sort of function that would say, "failed over to X interface." At best you can hope for reports on specific interfaces going up or down and you can easily figure out where it would have failed over to based on your policies.

It should be fairly easy for you to make a hotplug script which calls other scripts based on ifup and ifdown hotplug events (requires you to track interfaces.) The latest GUI files in 1.0-14 allow you to edit a custom hotplug script which is entirely separate from the main mwan3 hotplug script so you can't bone it with mistakes or typos. That's about as far as I'm going to take this.

If you were so inclined you could (possibly) add the functionality you want to the custom script yourself.

It would require you to do the following:
1. determine that an interface has gone down (ifdown event)
2. scan mwan3 config and find all members containing this interface
3. scan mwan3 config and find all policies containing those members for failover/loadbalance
4. determine next failover/loadbalance device(s)
5. return that data and format it in some meaningful way

Edit: Who knows maybe when I'm bored I'll add something like this to the default custom hotplug script. Don't hold your breath.

(Last edited by arfett on 1 Jun 2013, 04:39)

I found an app for creating virtual wans of a physical wan which can be used to dial the same pppoe acount for several times.But it doesn't have route assignment and weak in load banlancing.So I want to use mwan3 to do the route assignment and load banlancing instead.Is it possible to pack them together? Here is the patch to add it to luci.

diff -Nuar a/applications/luci-macvlan/luasrc/controller/macvlan.lua c/applications/luci-macvlan/luasrc/controller/macvlan.lua
--- a/applications/luci-macvlan/luasrc/controller/macvlan.lua    1970-01-01 08:00:00.000000000 +0800
+++ c/applications/luci-macvlan/luasrc/controller/macvlan.lua    2012-09-20 16:20:28.000000000 +0800
@@ -0,0 +1,13 @@
+
+module("luci.controller.macvlan", package.seeall)
+
+function index()
+    if not nixio.fs.access("/etc/config/macvlan") then
+        return
+    end
+    
+    local page = entry({"admin", "network", "macvlan"}, cbi("macvlan"), _("macvlan"), 11)
+    page.i18n = "macvlan"
+    page.dependent = true
+    
+end
diff -Nuar a/applications/luci-macvlan/luasrc/model/cbi/macvlan.lua c/applications/luci-macvlan/luasrc/model/cbi/macvlan.lua
--- a/applications/luci-macvlan/luasrc/model/cbi/macvlan.lua    1970-01-01 08:00:00.000000000 +0800
+++ c/applications/luci-macvlan/luasrc/model/cbi/macvlan.lua    2012-09-24 18:38:34.000000000 +0800
@@ -0,0 +1,98 @@
+local fs = require "nixio.fs"
+local sys = require "luci.sys"
+local wan_ifname = luci.util.exec("uci get network.wan.ifname")
+local wan1_ifname = luci.util.exec("uci get network.wan1.ifname")
+local wan2_ifname = luci.util.exec("uci get network.wan2.ifname")
+local wan3_ifname = luci.util.exec("uci get network.wan3.ifname")
+local wan4_ifname = luci.util.exec("uci get network.wan4.ifname")
+
+local function arplist(opt)
+    local _, e, mac, ip, name
+    local arp = { }
+
+    for _, e in ipairs(luci.sys.net.arptable()) do
+        arp[e["HW address"]:upper()] = { e["IP address"] }
+    end
+
+    if fs.access("/etc/ethers") then
+        for e in io.lines("/etc/ethers") do
+            mac, ip = e:match("^([a-f0-9]%S+) (%S+)")
+            if mac and ip then arp[mac:upper()] = { ip } end
+        end
+    end
+
+    if fs.access("/var/dhcp.leases") then
+        for e in io.lines("/var/dhcp.leases") do
+            mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
+            if mac and ip then arp[mac:upper()] = { ip, name ~= "*" and name } end
+        end
+    end
+
+    for mac, e in luci.util.kspairs(arp) do
+        opt:value(mac, "%s (%s)" %{ mac, e[2] or e[1] })
+    end
+end
+
+m = Map("macvlan", translate("macvlan"), translate("macvlanhelp"))
+
+s = m:section(TypedSection, "macvlan", translate("macvlan Settings"))
+s.anonymous = true
+s.addremove = true
+
+enabled = s:option(Flag, "enabled", translate("enabled"))
+enabled.optional = false
+enabled.rmempty = false
+
+ifname = s:option(Value, "ifname", translate("ifname"))
+ifname.optional = false
+ifname.rmempty = false
+ifname.default = wan_ifname
+ifname:value(wan_ifname,translate("WAN"))
+ifname:value(wan1_ifname,translate("WAN1"))
+ifname:value(wan2_ifname,translate("WAN2"))
+ifname:value(wan3_ifname,translate("WAN3"))
+ifname:value(wan4_ifname,translate("WAN4"))
+
+vlan = s:option(Value, "vlan", translate("vlan"), translate("vlanhelp"))
+vlan.optional = false
+vlan.rmempty = false
+
+zdy = s:option(Flag, "zdy", translate("zdy"), translate("zdyhelp"))
+zdy.optional = false
+zdy.rmempty = false
+
+xieyi = s:option(ListValue, "xieyi", translate("xieyi"))
+xieyi:value("dhcp", translate("DHCP"))
+xieyi:value("pppoe", translate("PPPoE"))
+xieyi.optional = false
+xieyi.rmempty = true
+xieyi:depends("zdy", "1")
+
+username = s:option(Value, "username", translate("username"))
+username.optional = false
+username.rmempty = true
+username:depends("xieyi", "pppoe")
+
+password = s:option(Value, "password", translate("password"))
+password.password = true
+password.optional = false
+password.rmempty = true
+password:depends("xieyi", "pppoe")
+
+s = m:section(TypedSection, "switch", translate("switch Settings"), translate("switchhelp"))
+s.anonymous=true
+s.addremove=false
+
+enabled = s:option(Flag, "enabled", translate("enabled"), translate("enabledhelp"))
+enabled.optional = false
+enabled.rmempty = false
+
+interfaces = s:option(ListValue, "interfaces", translate("interfacesd"))
+interfaces:value("2", translate("2"))
+interfaces:value("3", translate("3"))
+interfaces:value("4", translate("4"))
+interfaces:value("5", translate("5"))
+interfaces.optional = false
+interfaces.rmempty = true
+
+return m
diff -Nuar a/applications/luci-macvlan/Makefile c/applications/luci-macvlan/Makefile
--- a/applications/luci-macvlan/Makefile    1970-01-01 08:00:00.000000000 +0800
+++ c/applications/luci-macvlan/Makefile    2012-12-16 18:01:16.207264103 +0800
@@ -0,0 +1,4 @@
+PO = macvlan
+
+include ../../build/config.mk
+include ../../build/module.mk
diff -Nuar a/applications/luci-macvlan/root/etc/config/macvlan c/applications/luci-macvlan/root/etc/config/macvlan
--- a/applications/luci-macvlan/root/etc/config/macvlan    1970-01-01 08:00:00.000000000 +0800
+++ c/applications/luci-macvlan/root/etc/config/macvlan    2012-09-25 19:37:09.000000000 +0800
@@ -0,0 +1,9 @@
+config macvlan
+    option enabled '0'
+    option ifname ''
+    option vlan '2'
+    option zdy '0'
+
+config switch
+    option enabled '0'
+    option interfaces '2'
diff -Nuar a/applications/luci-macvlan/root/etc/init.d/macvlan c/applications/luci-macvlan/root/etc/init.d/macvlan
--- a/applications/luci-macvlan/root/etc/init.d/macvlan    1970-01-01 08:00:00.000000000 +0800
+++ c/applications/luci-macvlan/root/etc/init.d/macvlan    2012-09-30 03:42:32.000000000 +0800
@@ -0,0 +1,195 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+. /etc/functions.sh
+
+START=21
+
+name=$(uci get network.@switch[0].name)
+ports=$(uci get network.@switch_vlan[0].ports|awk -F" " '{ print $1 }')
+
+start() {
+    config_load macvlan
+    config_foreach delete macvlan
+    config_foreach switch_get switch
+    config_foreach macvlan_get macvlan
+    firewall
+}
+
+delete() {
+    config_get ifname $1 ifname
+    config_get sl $1 sl "1"
+    network=$(uci show network|fgrep .ifname="$ifname"|cut -d"." -f2)
+    n=$(echo "$network"|sed 's/wan//')
+    vth=$(uci show network|fgrep .ifname|grep -c vth)
+    switch=$(uci show network|grep -c "device=$name")
+    while [ "$vth" -ne 0 ];
+    do
+    ip link del vth$((n*100 + sl))
+    uci delete network.vth$((n*100 + sl))
+    uci delete dhcp.vth$((n*100 + sl))
+    sl=$((sl+1))
+    vth=$(uci show network|fgrep .ifname|grep -c vth)
+    done
+    [ $ports == 0 ] && {
+    while [ "$switch" -ne 1 ];
+    do
+    vlan=$(uci get network.@switch_vlan[-1].vlan)
+    interface=$(uci show network|grep "ifname=$name.$vlan"|cut -d"." -f2)
+    ifdown $interface
+    [ $(uci get macvlan.@switch[-1].enabled) == 0 ] && uci delete network.$interface
+    uci delete network.@switch_vlan[-1]
+    uci set network.@switch_vlan[0].ports="0 1 2 3 4"
+    uci set network.lan.ifname=$name
+    switch=$(uci show network|grep -c "device=$name")
+    done
+    }
+    [ $ports == 0t ] && {
+    while [ "$switch" -ne 2 ];
+    do
+    vlan=$(uci get network.@switch_vlan[-1].vlan)
+    interface=$(uci show network|grep "ifname=$name.$vlan"|cut -d"." -f2)
+    ifdown $interface
+    [ $(uci get macvlan.@switch[-1].enabled) == 0 ] && uci delete network.$interface
+    uci delete network.@switch_vlan[-1]
+    uci set network.@switch_vlan[0].ports="0t 2 3 4 5"
+    switch=$(uci show network|grep -c "device=$name")
+    done
+    }
+}
+
+switch_get() {
+    config_get enabled $1 enabled
+    config_get interfaces $1 interfaces
+    [ $enabled == 1 ] && {
+        [ $ports == 0 ] && {
+        case $interfaces in
+        2)
+        uci set network.@switch_vlan[0].ports="0 2 3 4"
+        uci set network.lan.ifname="$name".1
+        ;;
+        3)
+        uci set network.@switch_vlan[0].ports="0 3 4"
+        uci set network.lan.ifname="$name".1
+        ;;
+        4)
+        uci set network.@switch_vlan[0].ports="0 4"
+        uci set network.lan.ifname="$name".1
+        ;;
+        5)
+        uci set network.@switch_vlan[0].ports="0"
+        uci delete network.lan.ifname
+        ;;
+        esac
+        while [ $interfaces -gt 1 ];
+        do
+        uci add network switch_vlan
+        uci set network.@switch_vlan[-1].device=$name
+        uci set network.@switch_vlan[-1].vlan=$interfaces
+        uci set network.@switch_vlan[-1].ports="0t $((interfaces-1))"
+        if [ -z $(uci get network.wan"$((interfaces-1))") ]; then
+        uci set network.wan"$((interfaces-1))"=interface
+        uci set network.wan"$((interfaces-1))".ifname=${name}.$interfaces
+        uci set network.wan"$((interfaces-1))".proto=dhcp
+        uci set dhcp.wan"$((interfaces-1))"=dhcp
+        uci set dhcp.wan"$((interfaces-1))".interface=wan"$((interfaces-1))"
+        uci set dhcp.wan"$((interfaces-1))".ignore=1
+        fi
+        ifup wan"$((interfaces-1))"
+        interfaces=$((interfaces-1))
+        done
+        }
+        [ $ports == 0t ] && {
+        case $interfaces in
+        2)
+        uci set network.@switch_vlan[0].ports="0t 3 4 5"
+        ;;
+        3)
+        uci set network.@switch_vlan[0].ports="0t 4 5"
+        ;;
+        4)
+        uci set network.@switch_vlan[0].ports="0t 5"
+        ;;
+        5)
+        uci set network.@switch_vlan[0].ports="0t"
+        uci delete network.lan.ifname
+        ;;
+        esac
+        while [ $interfaces -gt 1 ];
+        do
+        uci add network switch_vlan
+        uci set network.@switch_vlan[-1].device=$name
+        uci set network.@switch_vlan[-1].vlan=$((interfaces+1))
+        uci set network.@switch_vlan[-1].ports="0t $interfaces"
+        if [ -z $(uci get network.wan"$((interfaces-1))") ]; then
+        uci set network.wan"$((interfaces-1))"=interface
+        uci set network.wan"$((interfaces-1))".ifname=${name}.$((interfaces+1))
+        uci set network.wan"$((interfaces-1))".proto=dhcp
+        uci set dhcp.wan"$((interfaces-1))"=dhcp
+        uci set dhcp.wan"$((interfaces-1))".interface=wan"$((interfaces-1))"
+        uci set dhcp.wan"$((interfaces-1))".ignore=1
+        fi
+        ifup wan"$((interfaces-1))"
+        interfaces=$((interfaces-1))
+        done
+        }
+    }
+}
+
+macvlan_get() {
+    config_get enabled $1 enabled
+    config_get macaddr $1 macaddr
+    config_get zdy $1 zdy
+    config_get ifname $1 ifname
+    config_get vlan $1 vlan
+    config_get xieyi $1 xieyi
+    config_get username $1 username
+    config_get password $1 password
+    config_get sl $1 sl "1"
+    network=$(uci show network |fgrep .ifname="$ifname" |cut -d"." -f2)
+    n=$(echo "$network" |sed 's/wan//')
+    proto=$(uci get network."$network".proto)
+    user=$(uci get network."$network".username)
+    pass=$(uci get network."$network".password)
+    [ $enabled == 1 ] && {
+    while [ "$sl" -le "$vlan" ] ;
+    do
+    ip link add link $ifname vth$((n*100 + sl)) type macvlan
+    uci set network.vth$((n*100 + sl))=interface
+    uci set network.vth$((n*100 + sl)).ifname=vth$((n*100 + sl))
+    uci set network.vth$((n*100 + sl)).defaultroute=0
+    if [ $zdy -eq 1 ]; then
+    uci set network.vth$((n*100 + sl)).proto=$xieyi
+    [ $xieyi == pppoe ] && {
+    uci set network.vth$((n*100 + sl)).username=$username
+    uci set network.vth$((n*100 + sl)).password=$password
+    }
+    else
+    uci set network.vth$((n*100 + sl)).proto=$proto
+    [ $proto == pppoe ] && {
+    uci set network.vth$((n*100 + sl)).username=$user
+    uci set network.vth$((n*100 + sl)).password=$pass
+    }
+    fi
+    uci set dhcp.vth$((n*100 + sl))=dhcp
+    uci set dhcp.vth$((n*100 + sl)).interface=vth$((n*100 + sl))
+    uci set dhcp.vth$((n*100 + sl)).ignore=1
+    ifconfig vth$((n*100 + sl)) up
+    ifup vth$((n*100 + sl))
+    sl=$((sl+1))
+    done
+    }
+}
+
+firewall() {
+    proto=$(uci show network|fgrep .proto|cut -d"." -f2|grep [^lanloopback]|wc -l)
+    while [ $proto -ne 0 ] ;
+    do
+    firewall=`echo $firewall $(uci show network|fgrep .proto|cut -d"." -f2|grep [^lanloopback]|sed -n ${proto}p)`
+    proto=$((proto-1))
+    done
+    uci set firewall.@zone[1].network="$firewall"
+    uci commit network
+    uci commit firewall
+    uci commit dhcp
+}
+
diff -Nuar a/applications/luci-macvlan/root/etc/uci-defaults/luci-app-macvlan c/applications/luci-macvlan/root/etc/uci-defaults/luci-app-macvlan
--- a/applications/luci-macvlan/root/etc/uci-defaults/luci-app-macvlan    1970-01-01 08:00:00.000000000 +0800
+++ c/applications/luci-macvlan/root/etc/uci-defaults/luci-app-macvlan    2012-12-19 10:45:38.242321654 +0800
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+uci -q batch <<-EOF >/dev/null
+          delete ucitrack.@macvlan[-1]
+          add ucitrack macvlan
+          set ucitrack.@macvlan[-1].init=macvlan
+          commit ucitrack
+EOF
+
+chmod 755 /etc/init.d/macvlan
+/etc/init.d/macvlan enable
+
+rm -f /tmp/luci-indexcache
+exit 0

(Last edited by ranfish on 2 Jun 2013, 05:08)

Well I ended up being a little bored and updated the custom hotplug script which will be in the LuCI app 1.0-16

It creates a variable $REPORTDATA which you can put in your own line to call your e-mail app, etc, etc.

Here are the contents of my $REPORTDATA variable after running 'ACTION=ifup DEVICE=eth0.1 INTERFACE=wan /sbin/hotplug-call iface'

Interface [ wan (eth0.1) ] on router [ OpenWRT-F70 ] has triggered an [ ifup ] hotplug event on Mon Jun  3 14:42:27 PDT 2013

---------------
CURRENT STATUS:
---------------

wan - ONLINE (monitored)

-----------------
MEMBERS AFFECTED:
-----------------

wan_m1_w3
wan_m2_w3

------------------
POLICIES AFFECTED:
------------------

wan_only:
wan_m1_w3

wan_both:
wan_m1_w3
wan_m2_w3

---------------
RULES AFFECTED:
---------------

internet:
source address - 
source port - 
destination address - 
destination port - 
protocol - all
policy assigned - wan_only
equalize - No

------------------------------------------------------------------
Last 50 MWAN3 systemlog entries. Newest entries sorted at the top:
------------------------------------------------------------------

Jun  3 14:42:26 OpenWRT-F70 user.notice mwan3: ifup interface wan (eth0.1)
Jun  3 14:41:28 OpenWRT-F70 user.notice mwan3: ifup interface wan (eth0.1)

(Last edited by arfett on 3 Jun 2013, 22:42)

arfett, nice job! I can't give feedback for the new additions in LuCI app, but I can comment Adze's latest changes:

I think that the load balancing is working much better, now almost every second refresh on cmyip.com, shows a different IP address, plus, I "feel" like that the overall load is lower.

As I mentioned in a previous post, I have solved my issues and now everything is working fine, speeds are blazing fast, routing policies ok, etc.

Once, Adze and arfett, a big "Thank You!" for this gem of code.

ranfish wrote:

I found an app for creating virtual wans of a physical wan which can be used to dial the same pppoe acount for several times.But it doesn't have route assignment and weak in load banlancing.So I want to use mwan3 to do the route assignment and load banlancing instead.Is it possible to pack them together?

I have been playing with macvlan and found out that macvlan works with mwan3. You should be able to create multiple virtual wans on one physical wan and use them with mwan3. Here is how i did it:

Create the /etc/init.d/macvlan file (kmod-macvlan must be installed):

#!/bin/sh /etc/rc.common
START=17

start() {
    ip link add link eth0 eth2 type macvlan
    ifconfig eth2 hw ether C6:3D:C7:02:02:02
 
    ip link add link eth0 eth3 type macvlan
    ifconfig eth3 hw ether C6:3D:C7:03:03:03    
}

stop() {
    ip link del link eth0 eth2
    ip link del link eth0 eth3
}

restart() {
    stop
    start
}

Replace "eth0" with your physical wan device. Replace "eth2" and "eth3" with names of your liking (they must not already be in use). Make this script at boot (run: "/etc/init.d/macvlan enable").

Now you can define the devices "eth2" and "eth3" in your network config file and subsequent the interfaces in mwan3.

(Last edited by Adze on 3 Jun 2013, 21:34)

headless.cross wrote:

I can't give feedback for the new additions in LuCI app .. Once, Adze and arfett, a big "Thank You!" for this gem of code.

Thanks but I certainly welcome criticism from you or anyone on the LuCI app. I feel like I have a pretty good idea of what makes a good interface but if it can be better I want to make it better.

arfett wrote:

Thanks but I certainly welcome criticism from you or anyone on the LuCI app. I feel like I have a pretty good idea of what makes a good interface but if it can be better I want to make it better.

I mean that I can't give feedback about the hotplug section (I don't think I will use it in the near future). Overall, the whole luci-app package is very good and working well. One thing that would be perfect, it's the rename function of an interface/member/rule during edit. As a software developer, I completely feel that you want to make it perfect (I think it's time to start playing with Lua and openwrt development).

headless.cross wrote:

I mean that I can't give feedback about the hotplug section (I don't think I will use it in the near future). Overall, the whole luci-app package is very good and working well. One thing that would be perfect, it's the rename function of an interface/member/rule during edit. As a software developer, I completely feel that you want to make it perfect (I think it's time to start playing with Lua and openwrt development).

I've wanted a rename feature but it's not really feasible unless the names are moved into the config sections. That would be a can of worms in and of itself so I have no hopes of ever implementing that.

eg

config interface
    option name 'wan'

(Last edited by arfett on 3 Jun 2013, 23:27)

arfett wrote:

I've wanted a rename feature but it's not really feasible unless the names are moved into the config sections.

eg

config interface
    option name 'wan'

That's a noticeable change in the config structure and the parsing function, imho.

(Last edited by headless.cross on 3 Jun 2013, 23:29)

arfett wrote:

Thanks but I certainly welcome criticism from you or anyone on the LuCI app. I feel like I have a pretty good idea of what makes a good interface but if it can be better I want to make it better.

Hello,arfett.
Here is another multiwan load balancing scripts and luci interface of it found in dev.openwrt.org.cn. I think it is a little bit easier to use.Maybe you can see to it as a reference to make your luci app more friendly to new user.

https://www.box.com/s/ddpazfpu37k1oc6uv9yv

ranfish wrote:

Hello,arfett.
Here is another multiwan load balancing scripts and luci interface of it found in dev.openwrt.org.cn. I think it is a little bit easier to use.Maybe you can see to it as a reference to make your luci app more friendly to new user.

https://www.box.com/s/ddpazfpu37k1oc6uv9yv

Easier in what way? Are you referring to the configuration of nwan being simpler than mwan3?

There's not much I can do about that as I'm working with MWAN3 and not nwan. If there's anything relevant to MWAN3 I'm all ears.

After looking at their Lua file it looks like a very simple page for configuring basically one thing. When I boot back over to linux I'll upload them and see what it looks like in case I missed something.

(Last edited by arfett on 4 Jun 2013, 09:57)

ranfish wrote:

Here is another multiwan load balancing scripts and luci interface of it found in dev.openwrt.org.cn. I think it is a little bit easier to use.

I have no experience with nwan (yet). But easier to use will probably mean less options to choose from...

I did some more testing with macvlan and i am happy to announce that with macvlan:

- mwan3 supports multiple virtual interfaces on one physical interface
- mwan3 supports multiple gateways with same ip address
- mwan3 supports multiple gateways on same device
- mwan3 supports routing of inbound traffic on all the active wans at the same time

Openwrt/netifd does not have support for macvlan interfaces yet, so you have to play with config a bit to get it working. Lets hope native macvlan support is added to Openwrt.

More info:

root@mercurius:~# cat /etc/init.d/macvlan 
#!/bin/sh /etc/rc.common
START=17

start() {
    ip link add link eth0 name eth0.1 type vlan id 1
    ip link add link eth0.1 eth2 type macvlan
    ifconfig eth2 hw ether C6:3D:C7:02:02:02
 
    ip link add link eth0 name eth0.2 type vlan id 2
    ip link add link eth0.2 eth3 type macvlan
    ifconfig eth3 hw ether C6:3D:C7:03:03:03    
}

stop() {
    ip link del link dev eth2

    ip link del link dev eth3
}

restart() {
    stop
    start
}


root@mercurius:~# 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 alias
    option interface 'loopback'
    option proto 'static'
    option ipaddr '192.168.1.1'
    option netmask '255.255.255.255'

config interface 'lan'
    option ifname 'eth1'
    option type 'bridge'
    option proto 'static'
    option ipaddr '192.168.33.2'
    option netmask '255.255.255.0'

config interface 'wan1'
    option ifname 'eth0.1'
    option proto 'static'
    option ipaddr '95.97.227.171'
    option netmask '255.255.255.248'
    option gateway '95.97.227.169'
    option dns '192.168.1.1 192.168.2.1'
    option metric '10'
    option accept_ra '1'

config interface 'wan2'
    option ifname 'eth0.2'
    option proto 'static'
    option ipaddr '213.154.232.11'
    option netmask '255.255.255.248'
    option gateway '213.154.232.9'
    option dns '192.168.1.1 192.168.2.1'
    option metric '20'
    option accept_ra '1'

config interface 'wan3'
        option ifname 'eth2'
        option proto 'static'
        option ipaddr '95.97.227.173'
        option netmask '255.255.255.248'
        option gateway '95.97.227.169'
        option dns '192.168.1.1 192.168.2.1'
        option metric '30'
        option accept_ra '1'

config interface 'wan4'
        option ifname 'eth3'
        option proto 'static'
        option ipaddr '213.154.232.13'
        option netmask '255.255.255.248'
        option gateway '213.154.232.9'
        option dns '192.168.1.1 192.168.2.1'
        option metric '40'
        option accept_ra '1'

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 '3 5t'

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

config switch_vlan
    option device 'rtl8366s'
    option vlan '3'
    option ports '1 5t'

config switch_vlan
    option device 'rtl8366s'
    option vlan '4'
    option ports '0 5t'


root@mercurius:~# cat /etc/config/firewall 
config rule
    option name 'Allow-Ping'
    option src 'wan'
    option proto 'icmp'
    option icmp_type 'echo-request'
    option family 'ipv4'
    option target 'ACCEPT'

config rule
    option name 'Allow-DHCP-Renew'
    option src 'wan'
    option proto 'udp'
    option dest_port '68'
    option target 'ACCEPT'
    option family 'ipv4'

config rule
    option name 'Allow-ICMPv6-Input'
    option src 'wan'
    option proto 'icmp'
    list icmp_type 'echo-request'
    list icmp_type 'echo-reply'
    list icmp_type 'destination-unreachable'
    list icmp_type 'packet-too-big'
    list icmp_type 'time-exceeded'
    list icmp_type 'bad-header'
    list icmp_type 'unknown-header-type'
    list icmp_type 'router-solicitation'
    list icmp_type 'neighbour-solicitation'
    list icmp_type 'router-advertisement'
    list icmp_type 'neighbour-advertisement'
    option limit '1000/sec'
    option family 'ipv6'
    option target 'ACCEPT'

config rule
    option name 'Allow-DHCPv6'
    option src 'wan'
    option proto 'udp'
    option src_ip 'fe80::/10'
    option src_port '547'
    option dest_ip 'fe80::/10'
    option dest_port '546'
    option family 'ipv6'
    option target 'ACCEPT'

config rule
    option name 'Allow-ICMPv6-Forward'
    option src 'wan'
    option dest '*'
    option proto 'icmp'
    list icmp_type 'echo-request'
    list icmp_type 'echo-reply'
    list icmp_type 'destination-unreachable'
    list icmp_type 'packet-too-big'
    list icmp_type 'time-exceeded'
    list icmp_type 'bad-header'
    list icmp_type 'unknown-header-type'
    option limit '1000/sec'
    option family 'ipv6'
    option target 'ACCEPT'

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

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

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

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

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


root@mercurius:~# cat /etc/config/mwan3 
config interface 'wan1'
    list track_ip '8.8.4.4'
    list track_ip '208.67.220.220'
    list track_ip '8.8.8.8'
    list track_ip '208.67.222.222'
    option enabled '1'
    option reliability '3'
    option count '1'
    option timeout '2'
    option interval '5'
    option up '8'
    option down '4'

config interface 'wan2'
    list track_ip '8.8.4.4'
    list track_ip '208.67.220.220'
    list track_ip '8.8.8.8'
    list track_ip '208.67.222.222'
    option enabled '1'
    option reliability '3'
    option count '1'
    option timeout '2'
    option interval '5'
    option up '8'
    option down '4'

config interface 'wan3'
    list track_ip '8.8.4.4'
    list track_ip '208.67.220.220'
    list track_ip '8.8.8.8'
    list track_ip '208.67.222.222'
    option enabled '1'
    option reliability '3'
    option count '1'
    option timeout '2'
    option interval '5'
    option up '8'
    option down '4'

config interface 'wan4'
    list track_ip '8.8.4.4'
    list track_ip '208.67.220.220'
    list track_ip '8.8.8.8'
    list track_ip '208.67.222.222'
    option enabled '1'
    option reliability '3'
    option count '1'
    option timeout '2'
    option interval '5'
    option up '8'
    option down '4'

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'

config member 'wan3_m1_w3'
    option interface 'wan3'
    option metric '1'
    option weight '3'

config member 'wan4_m1_w2'
    option interface 'wan4'
    option metric '1'
    option weight '2'

config policy 'wan1_only'
    list use_member 'wan1_m1_w3'

config policy 'wan2_only'
    list use_member 'wan2_m1_w2'

config policy 'wan1_wan2_wan3_wan4_loadbalanced'
    list use_member 'wan1_m1_w3'
    list use_member 'wan2_m1_w2'
    list use_member 'wan3_m1_w3'
    list use_member 'wan4_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'

config rule
    option dest_ip '192.168.0.0/16'
    option proto 'all'
    option use_policy 'default'

config rule
    option dest_ip '207.223.2.93'
    option use_policy 'wan1_pri_wan2_sec'

config rule
    option dest_ip '0.0.0.0/0'
    option proto 'tcp'
    option dest_port '80,443'
    option use_policy 'wan1_wan2_wan3_wan4_loadbalanced'

config rule
    option dest_ip '0.0.0.0/0'
    option equalize '1'
    option use_policy 'wan1_wan2_wan3_wan4_loadbalanced'
Adze wrote:

I did some more testing with macvlan and i am happy to announce that with macvlan:

- mwan3 supports multiple virtual interfaces on one physical interface
- mwan3 supports multiple gateways with same ip address
- mwan3 supports multiple gateways on same device
- mwan3 supports routing of inbound traffic on all the active wans at the same time

I am very happy to see your improvement.Just too much options for me as a non-guru.

ranfish wrote:

I am very happy to see your improvement.Just too much options for me as a non-guru.

What are you trying to do? You shouldn't need to be a guru to follow the instructions in the first post.

The only instructions lacking in the first post is routing router traffic as it doesn't go over the alias info which is talked about later.

We'll help you figure it out.

(Last edited by arfett on 5 Jun 2013, 00:30)

Awsome package. Many, many thx! Just what I have been looking for. And I am looking forward to having it in the official repos ASAP.

I have a little question: I am using a TP-Link WDR3600 router. What do you feel is the more stable solution for using mwan3. Attitude Adjustment 12.09 or Barrier Breaker Trunk? Are current versions of mwan3 tested on Attitude Adjustment or just on recent Trunk version?

Sorry, posts 326 to 325 are missing from our archive.