This is an old revision of the document!
Dual WAN with netifd
Introduction
- This instruction configures dual 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 dual 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 using PBR extras.
Save the failover script and assign the main and fallback interfaces.
Configure cron to run the failover script.
# Failover script cat << "EOF" > /root/2wan.sh NET_IF="wana" NET_FIF="wanb" . /lib/functions/network.sh network_flush_cache for IPV in 4 6 do NET_IF="${NET_IF}${IPV%4}" NET_FIF="${NET_FIF}${IPV%4}" eval network_get_device${IPV%4} NET_DEV "${NET_IF}" eval network_get_gateway${IPV%4} NET_GW "${NET_IF}" if ping -q -c 3 -w 5 -I \ "${NET_DEV}" "${NET_GW}" &> /dev/null then NET_RT="${NET_IF}" else NET_RT="${NET_FIF}" fi uci set network.default${IPV%4}.lookup="${NET_RT}" service network reload done EOF cat << "EOF" >> /etc/sysupgrade.conf /root/2wan.sh EOF # Configure cron cat << "EOF" >> /etc/crontabs/root * * * * * . /root/2wan.sh EOF uci set system.@system[0].cronloglevel="9" uci commit system service cron restart