Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docs:guide-user:network:wan:multiwan:2wan_netifd [2023/11/01 22:41] – [Command-line instructions] optimize code vgaeteradocs:guide-user:network:wan:multiwan:2wan_netifd [2023/11/10 09:08] (current) – migrated to docs:guide-user:network:wan:multiwan:mwan_netifd vgaetera
Line 1: Line 1:
-====== Dual WAN with netifd ====== 
-{{section>meta:infobox:howto_links#basic_skills&noheader&nofooter&noeditbutton}} 
- 
-===== Introduction ===== 
-  * This instruction configures dual WAN with [[docs:techref:netifd|netifd]] on OpenWrt. 
-  * Enable [[docs:guide-user:firewall:fw3_configurations:fw3_nat#ipv6_nat|IPv6 NAT or NPT]] and disable [[docs:guide-user:network:ipv6:ipv6_extras#disabling_ipv6_source_filter|IPv6 source filter]] if necessary. 
-  * Follow [[docs:guide-user:network:routing:pbr#pbr_with_netifd|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 [[docs:guide-user:advanced:pbr_extras|PBR extras]]. 
-Save the failover script and assign the main and fallback interfaces. 
-Configure cron to run the failover script. 
- 
-<code bash> 
-# Failover script 
-cat << "EOF" > /root/2wan.sh 
-NET_IF="wana" 
-NET_FIF="wanb" 
-. /lib/functions/network.sh 
-for IPV in 4 6 
-do 
-network_flush_cache 
-eval network_get_device${IPV%4} NET_DEV "${NET_IF}${IPV%4}" 
-eval network_get_gateway${IPV%4} NET_GW "${NET_IF}${IPV%4}" 
-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 
-NET_CRT="$(uci -q get network.default${IPV%4}.lookup)" 
-if [ "${NET_RT}" != "${NET_CRT}" ] 
-then logger -t 2wan "Switching to ${NET_RT}" 
-uci set network.default${IPV%4}.lookup="${NET_RT}" 
-service network reload 
-fi 
-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 
-</code> 
  
  • Last modified: 2023/11/01 22:41
  • by vgaetera