Help to configre MultiWAN

I Have Xiaomi MI3g Routter with OpenWRT

I want to setup failover between:

  • wana: wire internnet that connected to regular WAN port (DHCP), fast and default line
  • wanb: connection to annother wifi (as a client), slow but stable line

The goal is setup auttomatic switching to wanb when internet is missing on wana and switching back when wana becomes online

Here's my network config

# cat /etc/config/network

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

config globals 'globals'
	option packet_steering '1'
	option ula_prefix 'fdb3:d13a:3401::/48'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'lan1'
	list ports 'lan2'

config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
	option ip6assign '60'

config interface 'wan'
	option device 'wan'
	option proto 'dhcp'
	option force_link '1'
	option metric '10'
	option dns '8.8.8.8 8.8.4.4'
	option peerdns '0'

config device
	option name 'wan'
	option acceptlocal '1'
	option ipv6 '0'

config device
	option name 'eth1'
	option ipv6 '0'

config interface 'wanb'
	option proto 'dhcp'
	option metric '20'
	option device 'wlan0'
	option dns '8.8.8.8 8.8.4.4'
	option peerdns '0'

and mwan3 config

# cat /etc/config/mwan3

config globals 'globals'
	option mmx_mask '0x3F00'

config interface 'wan'
	list track_ip '1.0.0.1'
	list track_ip '1.1.1.1'
	list track_ip '208.67.222.222'
	list track_ip '208.67.220.220'
	option family 'ipv4'
	option reliability '2'
	option enabled '1'
	option initial_state 'online'
	option track_method 'ping'
	option count '1'
	option size '56'
	option max_ttl '60'
	option timeout '4'
	option interval '10'
	option failure_interval '5'
	option recovery_interval '5'
	option down '5'
	option up '5'

config policy 'wan_wanb'
	option last_resort 'default'
	list use_member 'wan_m1_w1'

config policy 'wanb_wan'
	list use_member 'wanb_m1_w1'
	option last_resort 'unreachable'

config rule 'default_rule_v4'
	option dest_ip '0.0.0.0/0'
	option family 'ipv4'
	option use_policy 'wan_wanb'

config interface 'wanb'
	option enabled '1'
	option initial_state 'online'
	option family 'ipv4'
	option track_method 'ping'
	option reliability '1'
	option count '1'
	option size '56'
	option max_ttl '60'
	option timeout '4'
	option interval '10'
	option failure_interval '5'
	option recovery_interval '5'
	option down '5'
	option up '5'

config rule 'failover'
	option family 'ipv4'
	option proto 'all'
	option sticky '0'
	option use_policy 'wanb_wan'

config member 'wan_m1_w1'
	option interface 'wan'
	option metric '1'
	option weight '1'

config member 'wanb_m1_w1'
	option interface 'wanb'
	option metric '1'
	option weight '1'

please help me to finish setup

  1. Member metrics are not correct for failover.
  2. Policies don't have a second member.
    Just use the default mwan3 configuration and change the use_policy in the default rule.
2 Likes

I reinstalled mwan3 and deleted stuff related to IPv6. What i have now, is it correct?

# cat /etc/config/mwan3

config globals 'globals'
	option mmx_mask '0x3F00'

config interface 'wan'
	option enabled '1'
	list track_ip '1.0.0.1'
	list track_ip '1.1.1.1'
	list track_ip '208.67.222.222'
	list track_ip '208.67.220.220'
	option family 'ipv4'
	option reliability '2'
	option initial_state 'online'
	option track_method 'ping'
	option count '1'
	option size '56'
	option max_ttl '60'
	option timeout '4'
	option interval '10'
	option failure_interval '5'
	option recovery_interval '5'
	option down '5'
	option up '5'

config interface 'wanb'
	list track_ip '1.0.0.1'
	list track_ip '1.1.1.1'
	list track_ip '208.67.222.222'
	list track_ip '208.67.220.220'
	option family 'ipv4'
	option reliability '1'
	option enabled '1'
	option initial_state 'online'
	option track_method 'ping'
	option count '1'
	option size '56'
	option max_ttl '60'
	option timeout '4'
	option interval '10'
	option failure_interval '5'
	option recovery_interval '5'
	option down '5'
	option up '5'

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 'wanb_m1_w2'
	option interface 'wanb'
	option metric '1'
	option weight '2'

config member 'wanb_m1_w3'
	option interface 'wanb'
	option metric '1'
	option weight '3'

config member 'wanb_m2_w2'
	option interface 'wanb'
	option metric '2'
	option weight '2'

config policy 'wan_only'
	list use_member 'wan_m1_w3'

config policy 'wanb_only'
	list use_member 'wanb_m1_w2'

config policy 'balanced'
	list use_member 'wan_m1_w3'
	list use_member 'wanb_m1_w3'

config policy 'wan_wanb'
	list use_member 'wan_m1_w3'
	list use_member 'wanb_m2_w2'
	option last_resort 'default'

config policy 'wanb_wan'
	list use_member 'wan_m2_w3'
	list use_member 'wanb_m1_w2'

config rule 'https'
	option sticky '1'
	option dest_port '443'
	option proto 'tcp'
	option use_policy 'balanced'

config rule 'default_rule_v4'
	option dest_ip '0.0.0.0/0'
	option family 'ipv4'
	option proto 'all'
	option sticky '0'
	option use_policy 'wan_wanb'

Yes, looks better. Either delete the https rule, or change its policy to wan_wanb.

2 Likes

ok, thanks
Should i add some script for instant wan switching or this enough ?

No need to add any script. You can adjust the timers up, down, failure_interval, recovery_interval, interval under interface section.

1 Like

i tested config, looks like it works
thanks a lot!

Very good! If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.
Thanks! :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.