{"id":49756887,"url":"https://github.com/mattackerman808/ipv6-wan-failover","last_synced_at":"2026-05-10T22:55:27.465Z","repository":{"id":345164167,"uuid":"1184769444","full_name":"mattackerman808/ipv6-wan-failover","owner":"mattackerman808","description":"Automatic IPv6 failover for UniFi Dream Machine dual-WAN setups","archived":false,"fork":false,"pushed_at":"2026-03-17T23:26:50.000Z","size":59,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-10T22:54:58.194Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattackerman808.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-17T23:13:21.000Z","updated_at":"2026-04-17T07:52:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mattackerman808/ipv6-wan-failover","commit_stats":null,"previous_names":["mattackerman808/ipv6-wan-failover"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mattackerman808/ipv6-wan-failover","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattackerman808%2Fipv6-wan-failover","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattackerman808%2Fipv6-wan-failover/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattackerman808%2Fipv6-wan-failover/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattackerman808%2Fipv6-wan-failover/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattackerman808","download_url":"https://codeload.github.com/mattackerman808/ipv6-wan-failover/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattackerman808%2Fipv6-wan-failover/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32874700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-10T13:40:02.631Z","status":"ssl_error","status_checked_at":"2026-05-10T13:40:02.145Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-10T22:55:26.712Z","updated_at":"2026-05-10T22:55:27.458Z","avatar_url":"https://github.com/mattackerman808.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ipv6-wan-failover\n\nAutomatic IPv6 failover for UniFi Dream Machine dual-WAN setups.\n\n## Problem\n\nOn a UDM with two WANs, IPv4 failover works instantly because NAT hides the source address — LAN devices keep their RFC 1918 addresses regardless of which WAN is active. IPv6 breaks because every LAN device has globally-routable addresses from the active WAN's prefix delegation. When that WAN goes down:\n\n- Devices still have IPv6 addresses from the dead WAN's prefix\n- Those addresses are not routable through the surviving WAN\n- New addresses require Router Advertisements, which can take 1+ hours\n- **All IPv6 connectivity is lost until then**\n\nUBIOS correctly switches the IPv4 default route and the IPv6 catch-all routing rule, but does not MASQUERADE traffic from the dead WAN's prefix through the surviving WAN.\n\n## How It Works\n\nThe daemon auto-detects your WAN topology (interfaces, routing tables, bridge-to-WAN mapping) from `ip -6 rule` and route table state. No configuration needed.\n\n**Detection:** Polls each WAN's routing table every 1 second. When a WAN's table loses its default route, that WAN is down.\n\n**Failover:** Adds two rules so LAN traffic from the dead WAN's prefix routes through the surviving WAN with NAT66:\n\n```bash\n# Route dead-prefix traffic via surviving WAN's table\nip -6 rule add from \u003cdead_prefix\u003e lookup \u003csurviving_table\u003e priority 50\n\n# Rewrite source address so upstream ISP accepts the traffic\nip6tables -t nat -A POSTROUTING -o \u003csurviving_wan\u003e -s \u003cdead_prefix\u003e -j MASQUERADE\n```\n\n**Recovery:** Removes both rules when the WAN comes back.\n\nThe daemon caches the bridge-to-WAN mapping at startup so it can still apply rules even if the dead WAN's prefix delegation expires during the outage.\n\n## Install\n\n```bash\n# Copy to the gateway (/data/ survives firmware updates)\nssh gateway 'mkdir -p /data/ipv6-wan-failover'\nscp ipv6-wan-failover.sh gateway:/data/ipv6-wan-failover/\nscp ipv6-wan-failover.service gateway:/etc/systemd/system/\n```\n\n## Usage\n\n```bash\n# Verify auto-detected topology\n/data/ipv6-wan-failover/ipv6-wan-failover.sh --status\n\n# Enable and start\nsystemctl daemon-reload\nsystemctl enable ipv6-wan-failover\nsystemctl start ipv6-wan-failover\n\n# Monitor\njournalctl -u ipv6-wan-failover -f\n\n# Show current state and active rules\n/data/ipv6-wan-failover/ipv6-wan-failover.sh --status\n\n# Manually remove all failover rules\n/data/ipv6-wan-failover/ipv6-wan-failover.sh --remove\n```\n\n**Note:** `/etc/systemd/system/` does not survive firmware updates. After a UDM firmware update, re-copy the service file and re-enable it. The script itself in `/data/` persists.\n\n## Relationship to fix-ipv6-wan2\n\n[fix-ipv6-wan2](https://github.com/mattackerman808/fix-ipv6-wan2) handles the **steady-state** problem: ensuring PBR devices and static routes use the correct WAN for IPv6 during normal dual-WAN operation. This project handles the **failover** problem: maintaining IPv6 connectivity when a WAN goes down entirely.\n\n| | fix-ipv6-wan2 | ipv6-wan-failover |\n|---|---|---|\n| **When** | Always (steady state) | Only during WAN failure |\n| **Scope** | Specific PBR devices + static routes | All LAN devices using the dead prefix |\n| **MASQUERADE** | PBR MACs through WAN2 | All dead-prefix traffic through surviving WAN |\n\n## License\n\nMIT License. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattackerman808%2Fipv6-wan-failover","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattackerman808%2Fipv6-wan-failover","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattackerman808%2Fipv6-wan-failover/lists"}