I wanted to create a backup connection to my network in case my main OPNSense firewall went down. I only want the backup connection online, if the main one goes offline.
- Setup OpenWRT on RPi3
- Installed mwan3
- Tried to follow the guide in OpenWRT Wiki
- Nothing about how to set up Failover with the second link off
How to:
- Set up both interfaces for WAN. In my case, VLAN 10 through my internal network as the main connection and (wan) and VLAN 110 directly to my ISP for failover (wanb)
- For wanb interface, uncheck
Bring up on boot
3. In the mwan3 config file or via the GUI, set the initial_state
of the failover (wanb) connection to offline
4. Modify the mwan3.user file to turn on the interface (wanb) when main connection goes down, and to turn it back off when main connection is online. I haven't fully tested the below, so I have it set to turn off the connection if there is an ifup
event or connected
event on the main connection(wan)
/etc/mwan3.user
#!/bin/sh
if [ "${ACTION}" = "disconnected" ] && [ "${INTERFACE}" = "wan" ] ; then
ifup wanb
/etc/init.d/ddns restart
fi
if [ "${ACTION}" = "connected" ] && [ "${INTERFACE}" = "wan" ] ; then
ifdown wanb
/etc/init.d/ddns restart
fi
if [ "${ACTION}" = "ifup" ] && [ "${INTERFACE}" = "wan" ] ; then
ifdown wanb
/etc/init.d/ddns restart
fi
mwan3 config file for reference
/etc/config/mwan3
config globals 'globals'
option mmx_mask '0x3F00'
option logging '1'
option loglevel 'info'
config interface 'wan'
option enabled '1'
list track_ip '1.1.1.1'
option family 'ipv4'
option initial_state 'online'
option track_method 'ping'
option reliability '1'
option count '1'
option size '56'
option max_ttl '60'
option check_quality '0'
option timeout '4'
option interval '10'
option failure_interval '5'
option recovery_interval '5'
option down '5'
option up '5'
list flush_conntrack 'ifup'
config interface 'wanb'
list track_ip '8.8.4.4'
list track_ip '8.8.8.8'
option family 'ipv4'
option reliability '1'
option enabled '1'
option initial_state 'offline'
option track_method 'ping'
option count '1'
option size '56'
option max_ttl '60'
option check_quality '0'
option timeout '4'
option interval '10'
option failure_interval '5'
option recovery_interval '5'
option down '5'
option up '5'
list flush_conntrack 'ifup'
config member 'wan_m1_w3'
option interface 'wan'
option metric '1'
option weight '100'
config member 'wanb_m2_w2'
option interface 'wanb'
option metric '2'
option weight '2'
config policy 'wan_wanb'
list use_member 'wan_m1_w3'
list use_member 'wanb_m2_w2'
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'
Useful References: