Show pagesourceOld revisionsBacklinksBack to top × Table of Contents MWAN with netifd Introduction Features Command-line instructions MWAN with netifd This article relies on the following: Accessing web interface / command-line interface Managing configs / packages / services / logs Introduction This instruction configures multi-WAN with netifd on OpenWrt. Enable IPv6 NAT or NPT and disable IPv6 source filter if necessary. Follow PBR with netifd for setting up PBR. Features Implement multi-WAN based on PBR with netifd. Perform connectivity check with ICMP and ICMPv6. Provide a simple failover method. Support dual-stack setups. Command-line instructions Assuming pre-configured upstream interfaces wana and wanb. Set up PBR with netifd. Save the failover script. Configure cron to run the failover script. # Configure network cat << EOF >> /etc/iproute2/rt_tables 1 wana 2 wanb EOF for IPV in 4 6 do uci set network.wana${IPV%4}.ip${IPV}table="wana" uci set network.wanb${IPV%4}.ip${IPV}table="wanb" uci -q delete network.default${IPV%4} uci set network.default${IPV%4}="rule${IPV%4}" uci set network.default${IPV%4}.lookup="wana" uci set network.default${IPV%4}.priority="80000" done uci commit network /etc/init.d/network restart # Failover script cat << "EOF" > /root/mwan.sh NET_IF="wana" NET_FIF="wanb" NET_IF6="${NET_IF}6" . /lib/functions/network.sh network_flush_cache network_get_device NET_DEV "${NET_IF}" network_get_device NET_DEV6 "${NET_IF6}" network_get_gateway NET_GW "${NET_IF}" network_get_gateway6 NET_GW6 "${NET_IF6}" for IPV in 4 6 do if ping -q -c 3 -w 5 -I \ "$(eval echo \${NET_DEV${IPV%4}})" \ "$(eval echo \${NET_GW${IPV%4}})" &> /dev/null then NET_RT="${NET_IF}" else NET_RT="${NET_FIF}" fi NET_CRT="$(uci -q get network.default${IPV%4}.lookup)" if [ "${NET_RT}" != "${NET_CRT}" ] then logger -t mwan "Switching to ${NET_RT}" uci set network.default${IPV%4}.lookup="${NET_RT}" /etc/init.d/network reload fi done EOF # Configure cron cat << "EOF" >> /etc/crontabs/root * * * * * . /root/mwan.sh EOF uci set system.@system[0].cronloglevel="9" uci commit system /etc/init.d/cron restart This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.OKMore information about cookies Last modified: 2023/09/22 12:56by vgaetera