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.

Philipp11 wrote:

It seems like the file is to be found in /bin/ip though.
Would it be ok to edit your
sbin/mwan3 to

#!/bin/sh
. /lib/functions.sh

IP="/usr/bin/ip -4"
IPS="/usr/sbin/ipset"
IPT="/usr/sbin/iptables -t mangle -w"

help()
{

Yes go ahead. You have to edit the /etc/hotplug.d/iface/15-mwan3 as well. Thanks for pointing that out.

(Last edited by Adze on 9 Oct 2015, 20:21)

For reference : I'm running trunk r47142  now.

after restarting mwan3 i got some ipset errors :

root@OpenWrt:~# mwan3 restart
ipset v6.24: The set with the given name does not exist
uci: Entry not found
uci: Entry not found
ipset v6.24: The set with the given name does not exist
uci: Entry not found
uci: Entry not found
ipset v6.24: The set with the given name does not exist
uci: Entry not found
uci: Entry not found

Tracking still wasn't working and all WANs appear offline in the luci app (even though they're working)
removed all track_ips, and voila my traffic passed through all gateways again.
in the luci-app my gateways still showed up as offline even though tracking was disabled :
PunBB bbcode test
In mwan3 the interfaces appear as online :

2
root@OpenWrt:~# mwan3 status
Interface status:
 interface wan is online
 interface wan2_1 is online
 interface wan2_2 is online

Policy balanced:
 wan2_1 (50%)
 wan2_2 (50%)

Policy balancedg2g3:
 unreachable

Policy express:
 wan2_2 (33%)
 wan2_1 (33%)
 wan (33%)

Policy wan2_only:
 wan2_1 (100%)

Policy wan2_wan:
 wan2_1 (100%)

Policy wan_only:
 wan (100%)

Policy wan_wan2:
 wan (100%)

Known networks:
 62.218.4.126
 192.168.20.0
 127.0.0.1
 192.168.20.37
 127.0.0.0
 192.168.0.255
 192.168.0.0
 127.0.0.0/8
 224.0.0.0/3
 192.168.20.255
 192.168.0.1
 86.32.217.1
 127.255.255.255
 192.168.0.0/24
 192.168.20.0/24
 192.168.20.38

Traffic was also beeing routed again by mwan3 to macvlan1 and macvlan2.

What happened seconds later when i tryed to start another ping from macvlan1 made me sad :

root@OpenWrt:~# ping -I macvlan1 google.at
PING google.at (64.15.113.182): 56 data bytes
^C
--- google.at ping statistics ---
59 packets transmitted, 0 packets received, 100% packet loss

So apparently the moment mwan3 starts to route traffic the interface shuts down... but only one of them. macvlan2 is still working the same as it was in CC.

When i tryed to use your integrated diagnostic tools to gather some information to post here i stumbled upon some more problems related to IP, here a small cutting from my troubleshooting data with the ip-problems :

Output of "ip rule show" : 

No data found

Output of "ip route list table 1-250" : 

No data found

I guess that's also related to the moved path of ip
When i manually enter these cvars i get a valid response :

root@OpenWrt:~# ip route list table 1-250
Error: argument "1-250" is wrong: table id value is invalid

root@OpenWrt:~# ip route list table 1
default via 62.218.4.126 dev pppoe-wan
root@OpenWrt:~# ip route list table 2
default via 192.168.20.4 dev macvlan1
root@OpenWrt:~# ip route list table 3
default via 192.168.20.1 dev macvlan2

root@OpenWrt:~# ip rule show
0:      from all lookup 128
1:      from all lookup local
1001:   from all iif pppoe-wan lookup main
1002:   from all iif macvlan1 lookup main
1003:   from all iif macvlan2 lookup main
2001:   from all fwmark 0x100/0xff00 lookup 1
2002:   from all fwmark 0x200/0xff00 lookup 2
2003:   from all fwmark 0x300/0xff00 lookup 3
2253:   from all fwmark 0xfd00/0xff00 blackhole
2254:   from all fwmark 0xfe00/0xff00 unreachable
32766:  from all lookup main
32767:  from all lookup default

Thats the whole log .. appears to be exactly the same as in CC

Software versions : 

OpenWrt - OpenWrt Designated Driver r47142
LuCI - git-15.278.60928-3289e13

mwan3 - 1.6-2
mwan3-luci - 1.4-3

Output of "cat /etc/config/mwan3" : 

config rule 'me'
    option src_ip '192.168.0.147'
    option proto 'all'
    option sticky '0'
    option use_policy 'wan_only'

config rule 'server_balanced'
    option proto 'all'
    option sticky '0'
    option src_ip '192.168.0.101'
    option use_policy 'balanced'

config rule 'dreamboxalwin'
    option proto 'all'
    option sticky '0'
    option src_ip '192.168.0.111'
    option use_policy 'wan_only'

config rule 'dreamboxgerry'
    option src_ip '192.168.0.112'
    option proto 'all'
    option sticky '0'
    option use_policy 'wan_only'

config rule 'dreamboxheidan'
    option src_ip '192.168.0.113'
    option proto 'all'
    option sticky '0'
    option use_policy 'wan_only'

config rule 'udp'
    option proto 'udp'
    option sticky '0'
    option use_policy 'wan_only'
    option src_ip '192.168.0.123'

config rule 'poe'
    option dest_port '6112'
    option proto 'tcp'
    option sticky '0'
    option use_policy 'wan_only'

config rule 'csgo'
    option use_policy 'wan_only'
    option sticky '0'
    option proto 'udp'
    option dest_port '27000:29000,25162,9899,20006,9989,13000'

config rule 'teamspeak'
    option proto 'udp'
    option use_policy 'wan_only'
    option dest_port '9987,1337'

config rule 'default_rule'
    option dest_ip '0.0.0.0/0'
    option proto 'all'
    option sticky '0'
    option use_policy 'balanced'

config rule 'sticky_even'
    option src_ip '0.0.0.0/0.0.0.1'
    option dest_port '443'
    option proto 'tcp'
    option use_policy 'wan_only'

config rule 'sticky_odd'
    option src_ip '0.0.0.1/0.0.0.1'
    option dest_port '443'
    option proto 'tcp'
    option use_policy 'wan2_wan'

config rule 'fifa'
    option dest_port '3659,9565,9570,9000:9999'
    option use_policy 'wan_only'
    option proto 'udp'
    option src_ip '192.168.0.123'

config interface 'wan'
    option enabled '1'
    option reliability '2'
    option count '1'
    option timeout '2'
    option interval '5'
    option down '3'
    option up '8'

config interface 'wan2_1'
    option reliability '1'
    option count '1'
    option down '3'
    option enabled '1'
    option timeout '4'
    option interval '10'
    option up '1'

config interface 'wan2_2'

    option reliability '1'
    option count '1'
    option down '3'
    option enabled '1'
    option timeout '4'
    option interval '10'
    option up '1'

config member 'wan_m1_w3'
    option interface 'wan'
    option metric '1'
    option weight '4'

config member 'wan_m2_w3'
    option interface 'wan'
    option metric '2'
    option weight '1'

config member 'wan2_m1_w2'
    option weight '4'
    option metric '1'
    option interface 'wan2_1'

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

config policy 'wan_only'
    list use_member 'wan_m1_w3'
    option last_resort 'default'

config policy 'wan2_only'
    list use_member 'wan2_m1_w2'

config policy 'balanced'
    option last_resort 'default'
    list use_member 'wan2_2_m1_w2'
    list use_member 'wan2_m1_w2'
    list use_member 'wan_m2_w3'

config policy 'wan_wan2'
    list use_member 'wan_m1_w3'
    list use_member 'wan2_m2_w2+'

config policy 'wan2_wan'
    list use_member 'wan_m2_w3'
    list use_member 'wan2_m1_w2'

config policy 'balancedg2g3'

config member 'wan2_2_m1_w2'
    option interface 'wan2_2'
    option weight '4'
    option metric '1'

config policy 'express'
    list use_member 'wan_m1_w3'
    list use_member 'wan2_m1_w2'
    list use_member 'wan2_2_m1_w2'

Output of "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 interface 'lan'
    option ifname 'eth1.1'
    option proto 'static'
    option type 'bridge'
    option ipaddr '192.168.0.1'
    option netmask '255.255.255.0'
    option dns '8.8.8.8'

config interface 'wan'
    option proto 'pppoe'
    USERNAME HIDDEN
    PASSWORD HIDDEN
    option metric '10'
    option _orig_ifname 'eth0'
    option _orig_bridge 'false'
    option ifname 'eth0'

config interface 'wan2'
    option ifname 'eth1.3'
    option proto 'none'

config device 'macvlan1'
    option ifname 'eth1.3'
    option type 'macvlan'
    option name 'macvlan1'
    option macaddr 'B0:48:7A:FF:36:95'

config device 'macvlan2'
    option ifname 'eth1.3'
    option type 'macvlan'
    option name 'macvlan2'
    option macaddr 'B0:48:7A:FF:36:96'

config interface 'wan2_1'
    option ifname 'macvlan1'
    option proto 'static'
    option ipaddr '192.168.20.38'
    option netmask '255.255.255.0'
    option gateway '192.168.20.4'
    option metric '20'
    option dns '213.73.91.35 8.8.8.8'

config interface 'wan2_2'
    option ifname 'macvlan2'
    option proto 'static'
    option ipaddr '192.168.20.37'
    option netmask '255.255.255.0'
    option metric '30'
    option dns '213.73.91.35 8.8.8.8'
    option gateway '192.168.20.1'

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

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

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

config switch_vlan
    option device 'switch0'
    option vlan '2'
    option ports '5 6'
    option vid '2'

Output of "ifconfig" : 

br-lan    Link encap:Ethernet  HWaddr 14:CC:20:A9:2E:36  
          inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::16cc:20ff:fea9:2e36/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:120703 errors:0 dropped:2 overruns:0 frame:0
          TX packets:199184 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:10785739 (10.2 MiB)  TX bytes:240063187 (228.9 MiB)

eth0      Link encap:Ethernet  HWaddr 14:CC:20:A9:2E:37  
          inet6 addr: fe80::16cc:20ff:fea9:2e37/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:119784 errors:0 dropped:0 overruns:0 frame:0
          TX packets:67705 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:152984987 (145.8 MiB)  TX bytes:6905716 (6.5 MiB)
          Interrupt:4 

eth1      Link encap:Ethernet  HWaddr 14:CC:20:A9:2E:36  
          inet6 addr: fe80::16cc:20ff:fea9:2e36/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:379732 errors:0 dropped:1 overruns:2 frame:0
          TX packets:241153 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:109760421 (104.6 MiB)  TX bytes:245223112 (233.8 MiB)
          Interrupt:5 

eth1.1    Link encap:Ethernet  HWaddr 14:CC:20:A9:2E:36  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:120766 errors:0 dropped:1 overruns:0 frame:0
          TX packets:198745 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:10787158 (10.2 MiB)  TX bytes:239967777 (228.8 MiB)

eth1.3    Link encap:Ethernet  HWaddr 14:CC:20:A9:2E:36  
          inet6 addr: fe80::16cc:20ff:fea9:2e36/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:257444 errors:0 dropped:0 overruns:0 frame:0
          TX packets:42389 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:92067969 (87.8 MiB)  TX bytes:4287973 (4.0 MiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:112 errors:0 dropped:0 overruns:0 frame:0
          TX packets:112 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8760 (8.5 KiB)  TX bytes:8760 (8.5 KiB)

macvlan1  Link encap:Ethernet  HWaddr B0:48:7A:FF:36:95  
          inet addr:192.168.20.38  Bcast:192.168.20.255  Mask:255.255.255.0
          inet6 addr: fe80::b248:7aff:feff:3695/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:189441 errors:0 dropped:0 overruns:0 frame:0
          TX packets:869 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:11368415 (10.8 MiB)  TX bytes:88505 (86.4 KiB)

macvlan2  Link encap:Ethernet  HWaddr B0:48:7A:FF:36:96  
          inet addr:192.168.20.37  Bcast:192.168.20.255  Mask:255.255.255.0
          inet6 addr: fe80::b248:7aff:feff:3696/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:257137 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41513 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:95624752 (91.1 MiB)  TX bytes:4198730 (4.0 MiB)

pppoe-wan Link encap:Point-to-Point Protocol  
          inet addr:86.32.217.1  P-t-P:62.218.4.126  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:119004 errors:0 dropped:0 overruns:0 frame:0
          TX packets:66918 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:150319585 (143.3 MiB)  TX bytes:5409147 (5.1 MiB)

wlan0     Link encap:Ethernet  HWaddr 14:CC:20:A9:2E:36  
          inet6 addr: fe80::16cc:20ff:fea9:2e36/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:739 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1700 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:97312 (95.0 KiB)  TX bytes:253803 (247.8 KiB)

Output of "route -n" : 

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         62.218.4.126    0.0.0.0         UG    10     0        0 pppoe-wan
0.0.0.0         192.168.20.4    0.0.0.0         UG    20     0        0 macvlan1
0.0.0.0         192.168.20.1    0.0.0.0         UG    30     0        0 macvlan2
62.218.4.126    0.0.0.0         255.255.255.255 UH    0      0        0 pppoe-wan
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 br-lan
192.168.20.0    0.0.0.0         255.255.255.0   U     20     0        0 macvlan1
192.168.20.0    0.0.0.0         255.255.255.0   U     30     0        0 macvlan2

Output of "ip rule show" : 

No data found

Output of "ip route list table 1-250" : 

No data found

Firewall default output policy (must be ACCEPT) : 

ACCEPT

Output of "iptables -L -t mangle -v -n" : 

Chain PREROUTING (policy ACCEPT 294K packets, 236M bytes)
 pkts bytes target     prot opt in     out     source               destination         
 306K  244M mwan3_hook  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
 294K  236M fwmark     all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain INPUT (policy ACCEPT 8967 packets, 1222K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 285K packets, 234M bytes)
 pkts bytes target     prot opt in     out     source               destination         
 285K  234M mssfix     all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain OUTPUT (policy ACCEPT 13367 packets, 3749K bytes)
 pkts bytes target     prot opt in     out     source               destination         
13978 3855K mwan3_hook  all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain POSTROUTING (policy ACCEPT 298K packets, 238M bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain fwmark (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain mssfix (1 references)
 pkts bytes target     prot opt in     out     source               destination         
  248 13128 TCPMSS     tcp  --  *      pppoe-wan  0.0.0.0/0            0.0.0.0/0            tcp flags:0x06/0x02 /* wan (mtu_fix) */ TCPMSS clamp to PMTU
  594 31352 TCPMSS     tcp  --  *      macvlan2  0.0.0.0/0            0.0.0.0/0            tcp flags:0x06/0x02 /* wan (mtu_fix) */ TCPMSS clamp to PMTU
    0     0 TCPMSS     tcp  --  *      eth1.3  0.0.0.0/0            0.0.0.0/0            tcp flags:0x06/0x02 /* wan (mtu_fix) */ TCPMSS clamp to PMTU
 1278 65392 TCPMSS     tcp  --  *      macvlan1  0.0.0.0/0            0.0.0.0/0            tcp flags:0x06/0x02 /* wan (mtu_fix) */ TCPMSS clamp to PMTU

Chain mwan3_connected (2 references)
 pkts bytes target     prot opt in     out     source               destination         
 164K  207M MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            match-set mwan3_connected dst MARK or 0xff00

Chain mwan3_hook (2 references)
 pkts bytes target     prot opt in     out     source               destination         
 320K  248M CONNMARK   all  --  *      *       0.0.0.0/0            0.0.0.0/0            CONNMARK restore mask 0xff00
 5372  490K mwan3_ifaces  all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00
 4261  400K mwan3_connected  all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00
 3681  332K mwan3_track  all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00
 3681  332K mwan3_rules  all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00
 320K  248M CONNMARK   all  --  *      *       0.0.0.0/0            0.0.0.0/0            CONNMARK save mask 0xff00
 260K  215M mwan3_connected  all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match ! 0xff00/0xff00

Chain mwan3_iface_wan (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 MARK       all  --  pppoe-wan *       0.0.0.0/0            0.0.0.0/0            match-set mwan3_connected src mark match 0x0/0xff00 /* default */ MARK or 0xff00
  797 64938 MARK       all  --  pppoe-wan *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 /* wan */ MARK xset 0x100/0xff00

Chain mwan3_iface_wan2_1 (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    3   385 MARK       all  --  macvlan1 *       0.0.0.0/0            0.0.0.0/0            match-set mwan3_connected src mark match 0x0/0xff00 /* default */ MARK or 0xff00
    0     0 MARK       all  --  macvlan1 *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 /* wan2_1 */ MARK xset 0x200/0xff00

Chain mwan3_iface_wan2_2 (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    3   385 MARK       all  --  macvlan2 *       0.0.0.0/0            0.0.0.0/0            match-set mwan3_connected src mark match 0x0/0xff00 /* default */ MARK or 0xff00
  308 24654 MARK       all  --  macvlan2 *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 /* wan2_2 */ MARK xset 0x300/0xff00

Chain mwan3_ifaces (1 references)
 pkts bytes target     prot opt in     out     source               destination         
 5370  490K mwan3_iface_wan2_1  all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00
 4803  434K mwan3_iface_wan2_2  all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00
 4117  369K mwan3_iface_wan  all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00

Chain mwan3_policy_balanced (2 references)
 pkts bytes target     prot opt in     out     source               destination         
  788 49399 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 statistic mode random probability 0.50000000000 /* wan2_1 4 8 */ MARK xset 0x200/0xff00
  874 57269 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 /* wan2_2 4 4 */ MARK xset 0x300/0xff00

Chain mwan3_policy_balancedg2g3 (0 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 /* unreachable */ MARK xset 0xfe00/0xff00

Chain mwan3_policy_express (0 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 statistic mode random probability 0.33300000010 /* wan2_2 4 12 */ MARK xset 0x300/0xff00
    0     0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 statistic mode random probability 0.50000000000 /* wan2_1 4 8 */ MARK xset 0x200/0xff00
    0     0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 /* wan 4 4 */ MARK xset 0x100/0xff00

Chain mwan3_policy_wan2_only (0 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 /* wan2_1 4 4 */ MARK xset 0x200/0xff00

Chain mwan3_policy_wan2_wan (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 /* wan2_1 4 4 */ MARK xset 0x200/0xff00

Chain mwan3_policy_wan_only (10 references)
 pkts bytes target     prot opt in     out     source               destination         
 1235  145K MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 /* wan 4 4 */ MARK xset 0x100/0xff00

Chain mwan3_policy_wan_wan2 (0 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 /* wan 4 4 */ MARK xset 0x100/0xff00

Chain mwan3_rules (1 references)
 pkts bytes target     prot opt in     out     source               destination         
  561 50132 mwan3_policy_wan_only  all  --  *      *       192.168.0.147        0.0.0.0/0            mark match 0x0/0xff00 /* me */
   10   673 mwan3_policy_balanced  all  --  *      *       192.168.0.101        0.0.0.0/0            mark match 0x0/0xff00 /* server_balanced */
    1   309 mwan3_policy_wan_only  all  --  *      *       192.168.0.111        0.0.0.0/0            mark match 0x0/0xff00 /* dreamboxalwin */
    1   309 mwan3_policy_wan_only  all  --  *      *       192.168.0.112        0.0.0.0/0            mark match 0x0/0xff00 /* dreamboxgerry */
    1   309 mwan3_policy_wan_only  all  --  *      *       192.168.0.113        0.0.0.0/0            mark match 0x0/0xff00 /* dreamboxheidan */
  512 86369 mwan3_policy_wan_only  udp  --  *      *       192.168.0.123        0.0.0.0/0            multiport sports 0:65535 multiport dports 0:65535 mark match 0x0/0xff00 /* udp */
    0     0 mwan3_policy_wan_only  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            multiport sports 0:65535 multiport dports 6112 mark match 0x0/0xff00 /* poe */
  159  7616 mwan3_policy_wan_only  udp  --  *      *       0.0.0.0/0            0.0.0.0/0            multiport sports 0:65535 multiport dports 27000:29000,25162,9899,20006,9989,13000 mark match 0x0/0xff00 /* csgo */
    0     0 mwan3_policy_wan_only  udp  --  *      *       0.0.0.0/0            0.0.0.0/0            multiport sports 0:65535 multiport dports 9987,1337 mark match 0x0/0xff00 /* teamspeak */
 1652  106K mwan3_policy_balanced  all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x0/0xff00 /* default_rule */
    0     0 mwan3_policy_wan_only  tcp  --  *      *       0.0.0.0/0.0.0.1      0.0.0.0/0            multiport sports 0:65535 multiport dports 443 mark match 0x0/0xff00 /* sticky_even */
    0     0 mwan3_policy_wan2_wan  tcp  --  *      *       0.0.0.1/0.0.0.1      0.0.0.0/0            multiport sports 0:65535 multiport dports 443 mark match 0x0/0xff00 /* sticky_odd */
    0     0 mwan3_policy_wan_only  udp  --  *      *       192.168.0.123        0.0.0.0/0            multiport sports 0:65535 multiport dports 3659,9565,9570,9000:9999 mark match 0x0/0xff00 /* fifa */

Chain mwan3_track (1 references)
 pkts bytes target     prot opt in     out     source               destination#

Regarding macvlan I'm really sad to see that using the newest trunk didn't help.
I could maybe downgrade back to CC and compile it myself with the proposed changes in the troubleticket hmm

(Last edited by Philipp11 on 9 Oct 2015, 20:43)

Hmmm, have to look into this. Probably some things have changed in current trunk.

Maybe you could start over and use the Stable (Chaos Calmer) version in the mean time?

(Last edited by Adze on 9 Oct 2015, 20:40)

Yep, going to do that.
The stable version doesn't have the proposed fix from https://dev.openwrt.org/ticket/20556 though.
r46767 is the stable version, it apparently broke with r46436 and got fixed with r47042.
Should i be looking into making my own build with the proposed changes or does it rather look like a different problem now that exactly the same problem persists in the most recent trunk?

Hard to tell, what i would suggest is revert the 303 patch and test some more with macvlans before installing mwan3. It is probably going to take you quite some time..

Maybe start bug ticket yourself?

(Last edited by Adze on 9 Oct 2015, 20:55)

Yep
Thanks for  accompanying me up to this point and pointing me towards the right direction, there are several paths to explore now and I'll carefully scan through every single one of them and stop spaming your thread on the way tongue.
Once i  have a stable setup surrounding macvlan running or an answered bugticket and maybe even a solution i will definitely  report back smile

kudos to you!

(Last edited by Philipp11 on 9 Oct 2015, 23:55)

I will be loading the new trunk this weekend to find out why the interfaces show as offline. I will upload to github soon.

I am getting the same thing with mwan3 on Barrier Breaker
It is leaking processes and consuming CPU usage.
Please fix this ASAP
The following is the list of processes it is leaking 11% is the CPU usage

4136                root                /usr/sbin/ip -4 rule list                11%                1%               
4137                root                awk $1 == "2254:                11%                1%

(Last edited by alphasparc on 10 Oct 2015, 13:42)

I looked at mwan3-luci today and I now know which part of the Lua scripting is not working on trunk but I have no idea how to fix it.

https://forum.openwrt.org/viewtopic.php?id=60262

(Last edited by arfett on 12 Oct 2015, 06:35)

Very high cpu usage.Now I combine 2*15mbps VDSL with mwan3 lastest version on ASUS N16. Surfing webs is very laggy when downloading.
http://i11.tietuku.com/703799e9936a6e2f.png

Hi guys! Nice to know there is a thread for discuss mwan3 .
Well, i've decided to use mwan3 to replace a very old script made by me to use dual wan.
Unfortunatelly i am getting all kinds of problems, and maybe someone can help me. A few of them looks like a bug, so i am gonna describe them

Environment: CHAOS CALMER (Chaos Calmer, r47004) running on buffalo AG-300H

Problems:

#1 The moment the interface which holds the 'default gateway' goes down, all local generated traffic stops routing. For example dnsmasq wont be able to resolv the names anymore, so the network appears to off for the users using the dnsmasq server.
How to replicate:

Lets stop both wan and wan2
# idown wan ; ifdown wan2
# ip route
192.168.254.0/24 dev br-lan  proto kernel  scope link  src 192.168.254.1
# ip rule
0:    from all lookup 128
1:    from all lookup local
2253:    from all fwmark 0xfd00/0xff00 blackhole
2254:    from all fwmark 0xfe00/0xff00 unreachable
32766:    from all lookup main
32767:    from all lookup default

now lets enable wan
# ifup wan
# ip route
default via 187.115.211.13 dev pppoe-wan  proto static
187.115.211.13 dev pppoe-wan  proto kernel  scope link  src 177.135.34.67
192.168.254.0/24 dev br-lan  proto kernel  scope link  src 192.168.254.1
# ip rule
0:    from all lookup 128
1:    from all lookup local
1001:    from all iif pppoe-wan lookup main
2001:    from all fwmark 0x100/0xff00 lookup 1
2253:    from all fwmark 0xfd00/0xff00 blackhole
2254:    from all fwmark 0xfe00/0xff00 unreachable
32766:    from all lookup main
32767:    from all lookup default

We can see that the pppoe-wan default gateway became the default gateway
now lets enable wan2

# ip route
default via 187.60.72.1 dev eth0.2  proto static  src 187.60.72.136
187.60.72.0/22 dev eth0.2  proto kernel  scope link  src 187.60.72.136
187.60.72.1 dev eth0.2  proto static  scope link  src 187.60.72.136
187.115.211.13 dev pppoe-wan  proto kernel  scope link  src 177.135.34.67
192.168.254.0/24 dev br-lan  proto kernel  scope link  src 192.168.254.1
# ip rule
0:    from all lookup 128
1:    from all lookup local
1001:    from all iif pppoe-wan lookup main
1002:    from all iif eth0.2 lookup main
2001:    from all fwmark 0x100/0xff00 lookup 1
2002:    from all fwmark 0x200/0xff00 lookup 2
2253:    from all fwmark 0xfd00/0xff00 blackhole
2254:    from all fwmark 0xfe00/0xff00 unreachable
32766:    from all lookup main
32767:    from all lookup default

Now the default gateway became the gateway from eth0.2 interface. No problem, since all the routing is done
by the mark thing.
The problems start if i disable wan2 interface, which holds the current default gateway.

# ifdown wan2
# ip route
187.115.211.13 dev pppoe-wan  proto kernel  scope link  src 177.135.34.67
192.168.254.0/24 dev br-lan  proto kernel  scope link  src 192.168.254.1
# ip rule
0:    from all lookup 128
1:    from all lookup local
1001:    from all iif pppoe-wan lookup main
2001:    from all fwmark 0x100/0xff00 lookup 1
2253:    from all fwmark 0xfd00/0xff00 blackhole
2254:    from all fwmark 0xfe00/0xff00 unreachable
32766:    from all lookup main
32767:    from all lookup default


Now linux does not have a 'global' default gateway, so dnsmasq cant resolve names:
# ping www.google.com
ping: bad address 'www.google.com'

if i add a dummy default gateway (any ip from my network even one not used) it will work again

# ip route add default via  192.168.254.111 (ip not in use)
# ping www.google.com -c1 -w2
PING www.google.com (177.43.170.110): 56 data bytes
64 bytes from 177.43.170.110: seq=0 ttl=60 time=8.351 ms

This shows that linux requires ANY default gateway in main table to work

I was able to fix this problem using this patch: i created.
It fixes two problems:
1) when the interface goes down and the current gw is lost, it will set the default gw for the first default gw it founds in any other table
2) It will stop complaining (a few times) with "Could not find gateway for interface..."

--- 15-mwan3
+++ 15-mwan3.new
@@ -1,5 +1,11 @@
 #!/bin/sh
 
+
+source  /usr/share/libubox/jshn.sh
+source /lib/functions/network.sh
+
+
+
 mwan3_get_iface_id()
 {
     let iface_count++
@@ -363,16 +369,11 @@
     if [ $ACTION == "ifup" ]; then
         [ "$enabled" -eq 1 ] || return 0
 
-        while [ -z "$($IP route list dev $DEVICE default | head -1)" -a "$counter" -lt 10 ]; do
-            sleep 1
-            let counter++
-            if [ "$counter" -ge 10 ]; then
-                $LOG warn "Could not find gateway for interface $INTERFACE ($DEVICE)" && return 0
-            fi
-        done
+        json_load "$(ifstatus $INTERFACE)"
+        network_get_gateway IFGW $INTERFACE
 
-        route_args=$($IP route list dev $DEVICE default | head -1 | sed '/.*via \([^ ]*\) .*$/!d;s//via \1/;q' | egrep '[0-9]{1,3}(\.[0-9]{1,3}){3}')
-        route_args="$route_args dev $DEVICE"
+        $LOG info gateway for interface $INTERFACE \(${DEVICE:-unknown}\) is $IFGW
+        route_args="via $IFGW dev $DEVICE"
     fi
 
     while [ "$(pgrep -f -o hotplug-call)" -ne $$ -a "$counter" -lt 60 ]; do
@@ -391,7 +392,14 @@
     mwan3_set_iface_route
     mwan3_set_iface_rules
 
-    [ $ACTION == "ifdown" ] && mwan3_set_iface_ipset
+    if [ $ACTION == "ifdown" ] ; then
+        mwan3_set_iface_ipset
+        if [ $(ip route | grep -c '^default via') == 0 ] ; then # NO DEFAULT GATEWAY FOR LOCAL TRAFFIC
+            NEW_GW=$(ip route show table all | grep '^default via' | head -1 | cut -d ' ' -f 3)
+            [ -n "$NEW_GW" ] && ip route add default via $NEW_GW || $LOG err No default gateway available
+        fi
+
+    fi
     [ $ACTION == "ifup" ] && mwan3_track
 
     config_foreach mwan3_set_policies_iptables policy

#2 This is not exactly a bug, but maybe a feature request
# Local generated traffic should honor the interface it is bound to.

How to replicate:
Lets stop both wan and wan2 interfaces, and test each one separately using the speedtest console client bind the source address to the right interface, just to become clear whats happening.
# ifdown wan
# ifdown wan2
# ifup wan
# speedtest_cli --server 5135  --source $(getip pppoe-wan)
Running speedtest.net console client
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Global Village Telecom (177.135.36.245)...
Testing download speed........................................
Download: 48.05 Mbits/s
Testing upload speed..................................................
Upload: 5320.10 Kbits/s


# ifdown wan
# ifup wan2

# speedtest_cli --server 5135  --source $(getip eth0.2)
Running speedtest.net console client
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Cabo Servicos De Telecomunicacoes Ltda (187.60.72.136)...
Testing download speed........................................
Download: 5.92 Mbits/s
Testing upload speed..................................................
Upload: 402.48 Kbits/s

The results are as expected, my main link is 50Mbit/5Mbit band the backup link 6Mbit/512kbit

# ifup wan (both interfaces are now up)

# speedtest_cli --server 5135  --source $(getip pppoe-wan)
Running speedtest.net console client
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Cabo Servicos De Telecomunicacoes Ltda (187.60.72.136)... -> I asked to bound to main link (getip pppoe-wan), it appears to have bound to the backup IP
Testing download speed........................................
Download: 21.09 Mbits/s
Testing upload speed..................................................
Upload: 504.31 Kbits/s
Very strange speeds.


I think that behaviour for local generated traffic is causing the next bug
# Interface not holding the default gateway changes to offline after a while.
After a while , the backup interface not holding the default gw just stop answering pings, and
it is put in offline state.  ()
# ip route
default via 187.115.211.13 dev pppoe-wan  proto static
# ping -I pppoe-wan 8.8.8.8 -c1
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=53 time=53.102 ms

--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 53.102/53.102/53.102 ms

#  ping -I eth0.2 8.8.8.8 -w 2 -c1
PING 8.8.8.8 (8.8.8.8): 56 data bytes

--- 8.8.8.8 ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss

I known that the interface is up, answering the ping for its gateway
# ping -I eth0.2 187.60.72.1  -w 2 -c1
PING 187.60.72.1 (187.60.72.1): 56 data bytes
64 bytes from 187.60.72.1: seq=0 ttl=255 time=9.696 ms

--- 187.60.72.1 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 9.696/9.696/9.696 ms

If i add the following rules the interface will work correctly:

ip rule add pref 501 oif pppoe-wan lookup 1
ip rule add pref 502 oif eth0.2 lookup 2


# ip rule
0:    from all lookup 128
1:    from all lookup local
501:    from all oif pppoe-wan lookup 1
502:    from all oif eth0.2 lookup 2
1001:    from all iif pppoe-wan lookup main
1002:    from all iif eth0.2 lookup main
2001:    from all fwmark 0x100/0xff00 lookup 1
2002:    from all fwmark 0x200/0xff00 lookup 2
2253:    from all fwmark 0xfd00/0xff00 blackhole
2254:    from all fwmark 0xfe00/0xff00 unreachable
32766:    from all lookup main
32767:    from all lookup default

# ping -I eth0.2 8.8.8.8 -w 2 -c1
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=54 time=55.013 ms

--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 55.013/55.013/55.013 ms

# ping -I pppoe-wan 8.8.8.8 -w 2 -c1
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=53 time=53.251 ms

--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 53.251/53.251/53.251 ms


I dont have luci interface installed, all the configuration was done by editing config files.

Hope someone can help!

salatiel wrote:

i am getting all kinds of problems, and maybe someone can help me. A few of them looks like a bug, so i am gonna describe them

Problems:

#1 The moment the interface which holds the 'default gateway' goes down, all local generated traffic stops routing. For example dnsmasq wont be able to resolv the names anymore, so the network appears to off for the users using the dnsmasq server.

This shows that linux requires ANY default gateway in main table to work

I was able to fix this problem using this patch: i created.
It fixes two problems:
1) when the interface goes down and the current gw is lost, it will set the default gw for the first default gw it founds in any other table
2) It will stop complaining (a few times) with "Could not find gateway for interface..."

Hi salatiel,

If you configure metrics (as described in the wiki) on all your wan interfaces, you would not have run into above problem. If you don't set metrics, new gateway settings will overwrite old gateway settings and routing information get lost. Please add metrics and try again.


salatiel wrote:

#2 This is not exactly a bug, but maybe a feature request
# Local generated traffic should honor the interface it is bound to.

It is already available to you in mwan3. You only need to create a mwan3 rule per wan interface. See wiki for more info.

Edit: all the extra's you configured yourself are totally unneeded. This is probably that you know a lot about linux routing and not so much about mwan3 (yet). Then when you face some routing hurdles with mwan3, you like to fix them with scripting. My advice is to read wiki once again, cause the issues you describe are very general, much seen issues.

(Last edited by Adze on 18 Oct 2015, 10:20)

Hi Adze, thanks for your reply. The metric thing did the trick. I've read the wiki (http://wiki.openwrt.org/doc/howto/mwan3) a few times and i am starting to understand. But could you please elaborate more the part that you say:

# Local generated traffic should honor the interface it is bound to.
It is already available to you in mwan3. You only need to create a mwan3 rule per wan interface. See wiki for more info.

config rule 'Mailserver_uses_wan3_only'
        option src_ip '172.16.1.20'
        option proto 'all'
        option use_policy 'wan3_only'

I think you refer to this snippet above, but how can i make it work with dhcp ?
Both WANs i use have dynamic ip.

btw, i forgot to ask, can i have  multiple "option src_ip" in some rule or i have to create several small rules ?

(Last edited by salatiel on 18 Oct 2015, 13:07)

Hi,

I just upgraded our custom OpenWRT build to use CC and the latest set of packages.

I am seeing a "new" behaviour, but perhaps it is normal for CC.  I am posting here as it seems to directly impact and effect MWAN3.

We use a 4G radio with the ncm protocol scripts.  We have customized these scripts quite a bit.  The second WAN is a wired connection to the router.  The MWAN config is quite simple.  Only one WAN is active at a time.

When the ncm interface comes up, we seem to be getting a second routing table created "2" with the default route.  When we were using BB and older packages, this did not happen.  Not sure why it's happening, or if it is a problem but don't understand why all of a sudden a second routing table is being created, when I don't think we need it.

Here is the table before the NCM device is brought up:

#ip route show table main
10.10.10.0/24 dev br-lan  proto kernel  scope link  src 10.10.10.1 
10.10.30.0/24 dev wlan0-1  proto kernel  scope link  src 10.10.30.1

# ip route show table 2

After the ncm interface is brought up:

# ip route show table main
default via 10.13.101.50 dev wwan0  proto static  metric 10 
10.10.10.0/24 dev br-lan  proto kernel  scope link  src 10.10.10.1 
10.10.30.0/24 dev wlan0-1  proto kernel  scope link  src 10.10.30.1 
10.13.101.50 dev wwan0  proto static  scope link  metric 10 

# ip route show table 2
default via 10.13.101.50 dev wwan0 

Now, in this state, MWAN status page shows as it should and seems to be working.

As a test, I "flushed" routing table 2.  When I do this, MWAN shows an error on the status page which leads me to think this table has something to do with MWAN??

Any point in the right direction would be great!

Edit:  To clarify one thing.  I first noticed this extra routing table because of Luci and the Routes page.  Perhaps it was a change in Luci that now displays these extra tables even though they have been there in BB also.....?

(Last edited by JohnV on 19 Oct 2015, 15:22)

JohnV wrote:

Hi,
I am seeing a "new" behaviour, but perhaps it is normal for CC.  I am posting here as it seems to directly impact and effect MWAN3.

Current versions of mwan3 create a routing table for each interface in the same order as the config (I think the mwan3 config.)

Table 1 for the first interface, table 2 for the second interface, etc. These tables are populated and flushed by the hotplug scripts on ifup/ifdown events.

(Last edited by arfett on 20 Oct 2015, 01:22)

Thanks for the clarification on the routing tables.

I have one additional issue/question with my migration to CC.

I have a Luci page that changes a mwan3 rule based on a UI selection.  With BB, when this change was saved, the rule was updated, interfaces went down/up, mwan3 seemed to restart, and everything was A-OK.  Data followed the rules updated in mwan3.

With CC, when the same Luci code is applied, the rule is updated, but when I look at the Detailed Status there is no traffic displayed on either rule, and the rules are not being enforced as all traffic seems to go out wan even if wan2 is specified in the rule.  If I reboot the router, when it comes up, everything is working OK.

Here is the code I use to change the rule, nothing special:

    if value == "wifi" then
        m.uci:set("mwan3", "guest_rule", "use_policy", "wan_only")
    else
        m.uci:set("mwan3", "guest_rule", "use_policy", "wan2_wan")
    end
    
    m.uci:save("mwan3")

Here is the status from MWAN that shows no data flowing:

Active rules:
    0     0 - wan2_wan  all  --  *      *       10.10.30.0/24        0.0.0.0/0            
    0     0 - wan2_wan  all  --  *      *       0.0.0.0/0            0.0.0.0/0

After reboot, as I wrote, it works fine and traffic flows as it should and the stats on the Detailed Status page update normally.


It would appear that something needs to get flushed or restarted manually to get everything working again after the rule change from my Luci page.....  Any ideas on what it might be?

If I can provide additional config to help diagnose just let me know.  And thank you!

I have been doing some more testing, and the results are inconsistent.  Sometimes when I make the rule change mwan3 comes back OK and everything works as it should.  More often then not however, mwan3 comes back in an odd state.

The "error" results are not consistent however.  One time after changing the rule, the detailed status showed no Known Networks even through the routing tables all looked OK.  Neither wan nor wan2 were working however.

Interface status:
 interface wan is online
 interface wan2 is online

Policy wan2_only:
 wan2 (100%)

Policy wan2_wan:
 wan2 (100%)

Policy wan_only:
 wan (100%)

Policy wan_wan2:
 wan (100%)

Known networks:

Active rules:
  153  9652 - wan_only  all  --  *      *       10.10.30.0/24        0.0.0.0/0            
  418 24363 - wan2_wan  all  --  *      *       0.0.0.0/0            0.0.0.0/0

(Last edited by JohnV on 20 Oct 2015, 23:02)

I sorted the issue by adding a "sleep 1" in the mwan restart function in /usr/sbin/mwan3.

This seems to be working.

Must be some conflict when a bunch of UCI changes are made at once and the interfaces are all coming back up.

salatiel wrote:

Hi Adze, thanks for your reply. The metric thing did the trick. I've read the wiki (http://wiki.openwrt.org/doc/howto/mwan3) a few times and i am starting to understand. But could you please elaborate more the part that you say:

# Local generated traffic should honor the interface it is bound to.
It is already available to you in mwan3. You only need to create a mwan3 rule per wan interface. See wiki for more info.

config rule 'Mailserver_uses_wan3_only'
        option src_ip '172.16.1.20'
        option proto 'all'
        option use_policy 'wan3_only'

I think you refer to this snippet above, but how can i make it work with dhcp ?
Both WANs i use have dynamic ip.

btw, i forgot to ask, can i have  multiple "option src_ip" in some rule or i have to create several small rules ?

Hello, ideas on the dhcp thing?

salatiel wrote:

Hello, ideas on the dhcp thing?

What is the issue you're having with DHCP? DHCP is handled by OpenWrt and goes out a particular interface and comes back to it. You don't need any mwan3 rules for your WAN interface DHCP.

(Last edited by arfett on 24 Oct 2015, 18:53)

Hi arfett, since i quote just part of the text i think you misunderstood me.
I was having problems with local traffic bound to a specific interface still being balanced, so Adze told me i should create a rule with source ip being my wan ip address. It works great this way, but since my wan ip is dynamic, i have to change the rule all the time. Maybe there was a way to do it.
Anyway, i have created a little patch to allow option src_ip 'wan' and option src_ip 'wan2' and it resolves the current ip address on the hotplug event.

I will post here , maybe someone finds useful.

--- 15-mwan3
+++ 15-mwan3.new
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+. /lib/functions/network.sh
+
 mwan3_get_iface_id()
 {
     let iface_count++
@@ -293,6 +295,14 @@
     config_get use_policy $1 use_policy
 
     rule="$1"
+
+    if  ! echo "$src_ip" | grep -E "[0-9]{1,3}(\.[0-9]{1,3}){3}" &>/dev/null ; then
+        iface=$src_ip
+        network_get_ipaddr src_ip $src_ip
+        [ -n "$src_ip" ] || return 0
+        $LOG info Using \'$src_ip\' from $iface as source ip for rule $rule.
+    fi
+
 
     if [ "$rule" != $(echo "$rule" | cut -c1-15) ]; then
         $LOG warn "Rule $rule exceeds max of 15 chars. Not setting rule" && return 0

I have a Netgear WNDR 3700 connected to an ADSL modem and a 3g usb stick. I would like to failover from ADSL to 3G when the former goes down. The openwrt version is  CHAOS CALMER (15.05, r46767)

I get the following error on starting mwan3. Also, when the ADSL cable is pulled out and re-inserted the ADSL connection doesnt come back on. Any idea what could be wrong?

#mwan3 start
uci: Entry not found
uci: Entry not found
uci: Entry not found
uci: Entry not found

My network

#/etc/config/network
config interface 'wan'
        option ifname 'eth1'
        option _orig_ifname 'eth1'
        option _orig_bridge 'false'
        option proto 'pppoe'
        option username 'username'
        option password 'password'
        option metric '10'
        option peerdns '0'
        option dns '8.8.8.8 218.248.255.204'

config interface 'wan2'
        option proto '3g'
        option device '/dev/ttyUSB0'
        option apn 'www'
        option dialnumber '*99#'
        option service 'umts'
        option metric '20'

Routes

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         113.192.16.1    0.0.0.0         UG    10     0        0 pppoe-wan
0.0.0.0         11.65.64.65     0.0.0.0         UG    20     0        0 3g-wan2
11.65.64.65     0.0.0.0         255.255.255.255 UH    0      0        0 3g-wan2
113.192.16.1    0.0.0.0         255.255.255.255 UH    0      0        0 pppoe-wan
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 br-lan

mwan

#/etc/config/mwan3
config interface 'wan'
        option enabled '1'
        list track_ip '8.8.4.4'
        list track_ip '8.8.8.8'
        list track_ip '208.67.222.222'
        list track_ip '208.67.220.220'
        option reliability '2'
        option count '1'
        option timeout '2'
        option interval '5'
        option down '3'
        option up '8'

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

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

config member 'wan_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'

config policy 'wan_only'
        list use_member 'wan_m1_w3'

config policy 'wan2_only'
        list use_member 'wan2_m1_w2'

config policy 'balanced'
        list use_member 'wan_m1_w3'
        list use_member 'wan2_m1_w2'

config policy 'wan_wan2'
        list use_member 'wan_m1_w3'
        list use_member 'wan2_m2_w2'

config policy 'wan2_wan'
        list use_member 'wan_m2_w3'
        list use_member 'wan2_m1_w2'


config rule 'default_rule'
        option dest_ip '0.0.0.0/0'
        option use_policy 'wan_wan2'

mwan3 status

# mwan3 status
Interface status:
 interface wan is online (tracking active)
 interface wan2 is online (tracking active)

Policy balanced:
 wan2 (40%)
 wan (60%)

Policy wan2_only:
 wan2 (100%)

Policy wan2_wan:
 wan2 (100%)

Policy wan_only:
 wan (100%)

Policy wan_wan2:
 wan (100%)

Known networks:
 127.0.0.0/8
 192.168.1.1
 127.0.0.1
 127.255.255.255
 224.0.0.0/3
 113.192.16.49
 192.168.1.255
 192.168.1.0/24
 127.0.0.0
 11.65.64.65
 192.168.1.0
 105.205.21.4
 113.192.16.1

Active rules:
  291 19862 - wan_wan2  all  --  *      *       0.0.0.0/0            0.0.0.0/0 

(Last edited by trumee on 1 Nov 2015, 16:29)

trumee wrote:

I get the following error on starting mwan3. Also, when the ADSL cable is pulled out and re-inserted the ADSL connection doesnt come back on. Any idea what could be wrong?

#mwan3 start
uci: Entry not found
uci: Entry not found
uci: Entry not found
uci: Entry not found

You are using an old version of mwan3 probably.

(Last edited by arfett on 1 Nov 2015, 18:37)