# Setup mwan3 for Multi-WAN Load Balancing and Failover # Configures 4× Spectrum WAN connections param( [string]$OpenWrtIP = "10.10.60.100", [string]$OpenWrtUser = "root" ) $ErrorActionPreference = "Stop" Write-Host "=========================================" -ForegroundColor Cyan Write-Host "mwan3 Multi-WAN Configuration" -ForegroundColor Cyan Write-Host "=========================================" -ForegroundColor Cyan Write-Host "`nThis script configures mwan3 for 4× Spectrum WAN load balancing and failover." -ForegroundColor Yellow # Check if OpenWrt is accessible Write-Host "`nChecking OpenWrt connectivity..." -ForegroundColor Yellow try { $ping = Test-Connection -ComputerName $OpenWrtIP -Count 1 -Quiet if (-not $ping) { Write-Host "OpenWrt is not reachable at $OpenWrtIP" -ForegroundColor Red Write-Host "Please ensure OpenWrt VM is running and accessible." -ForegroundColor Yellow exit 1 } } catch { Write-Host "Cannot reach OpenWrt at $OpenWrtIP" -ForegroundColor Red exit 1 } Write-Host "`nmwan3 Configuration Steps:" -ForegroundColor Cyan Write-Host "1. Install mwan3 on OpenWrt: opkg update && opkg install mwan3 luci-app-mwan3" -ForegroundColor White Write-Host "2. Configure WAN interfaces" -ForegroundColor White Write-Host "3. Configure health checks" -ForegroundColor White Write-Host "4. Configure load balancing rules" -ForegroundColor White Write-Host "`nExample mwan3 configuration:" -ForegroundColor Yellow $mwan3Config = @" # /etc/config/mwan3 # WAN1 interface config interface 'wan1' option enabled '1' option family 'ipv4' list track_ip '8.8.8.8' list track_ip '1.1.1.1' option reliability '2' option count '1' option timeout '2' option interval '5' option down '3' option up '3' # WAN2 interface config interface 'wan2' option enabled '1' option family 'ipv4' list track_ip '8.8.8.8' list track_ip '1.1.1.1' option reliability '2' option count '1' option timeout '2' option interval '5' option down '3' option up '3' # WAN3 interface config interface 'wan3' option enabled '1' option family 'ipv4' list track_ip '8.8.8.8' list track_ip '1.1.1.1' option reliability '2' option count '1' option timeout '2' option interval '5' option down '3' option up '3' # WAN4 interface config interface 'wan4' option enabled '1' option family 'ipv4' list track_ip '8.8.8.8' list track_ip '1.1.1.1' option reliability '2' option count '1' option timeout '2' option interval '5' option down '3' option up '3' # Member configuration - WAN1 config member 'wan1_m1_w3' option interface 'wan1' option metric '1' option weight '1' # Member configuration - WAN2 config member 'wan2_m1_w3' option interface 'wan2' option metric '1' option weight '1' # Member configuration - WAN3 config member 'wan3_m1_w3' option interface 'wan3' option metric '1' option weight '1' # Member configuration - WAN4 config member 'wan4_m1_w3' option interface 'wan4' option metric '1' option weight '1' # Policy - balanced (all WANs) config policy 'balanced' list use_member 'wan1_m1_w3' list use_member 'wan2_m1_w3' list use_member 'wan3_m1_w3' list use_member 'wan4_m1_w3' # Policy - wan1_only config policy 'wan1_only' list use_member 'wan1_m1_w3' # Policy - wan2_only config policy 'wan2_only' list use_member 'wan2_m1_w3' # Policy - wan3_only config policy 'wan3_only' list use_member 'wan3_m1_w3' # Policy - wan4_only config policy 'wan4_only' list use_member 'wan4_m1_w3' # Rule - default (use balanced) config rule 'default_rule' option dest_ip '0.0.0.0/0' option use_policy 'balanced' "@ Write-Host $mwan3Config -ForegroundColor Gray Write-Host "`nTo apply mwan3 configuration:" -ForegroundColor Yellow Write-Host "1. SSH to OpenWrt: ssh $OpenWrtUser@$OpenWrtIP" -ForegroundColor White Write-Host "2. Install mwan3: opkg update && opkg install mwan3 luci-app-mwan3" -ForegroundColor White Write-Host "3. Copy configuration to /etc/config/mwan3" -ForegroundColor White Write-Host "4. Restart mwan3: /etc/init.d/mwan3 restart" -ForegroundColor White Write-Host "5. Check status: mwan3 status" -ForegroundColor White Write-Host "`nHealth Check Configuration:" -ForegroundColor Cyan Write-Host "- Track IPs: 8.8.8.8 (Google DNS), 1.1.1.1 (Cloudflare DNS)" -ForegroundColor White Write-Host "- Reliability: 2 (require 2 successful pings)" -ForegroundColor White Write-Host "- Interval: 5 seconds" -ForegroundColor White Write-Host "- Timeout: 2 seconds" -ForegroundColor White Write-Host "- Down threshold: 3 failures" -ForegroundColor White Write-Host "- Up threshold: 3 successes" -ForegroundColor White Write-Host "`nLoad Balancing:" -ForegroundColor Cyan Write-Host "- All WANs have equal weight (1)" -ForegroundColor White Write-Host "- Traffic distributed across all active WANs" -ForegroundColor White Write-Host "- Automatic failover if WAN goes down" -ForegroundColor White Write-Host "`nTesting:" -ForegroundColor Yellow Write-Host "1. Check mwan3 status: mwan3 status" -ForegroundColor White Write-Host "2. Test connectivity: ping -I wan1 8.8.8.8" -ForegroundColor White Write-Host "3. Monitor traffic: mwan3 hw" -ForegroundColor White Write-Host "4. Check routing: ip route show table all" -ForegroundColor White Write-Host "`n=========================================" -ForegroundColor Cyan Write-Host "mwan3 Configuration Complete" -ForegroundColor Cyan Write-Host "=========================================" -ForegroundColor Cyan