Skip to content

feat: Add support for dual-stack IPv4/IPv6 configurations#2609

Open
farhadh wants to merge 7 commits into
amnezia-vpn:devfrom
farhadh:feat/farhadh/support-ipv6
Open

feat: Add support for dual-stack IPv4/IPv6 configurations#2609
farhadh wants to merge 7 commits into
amnezia-vpn:devfrom
farhadh:feat/farhadh/support-ipv6

Conversation

@farhadh
Copy link
Copy Markdown

@farhadh farhadh commented May 16, 2026

Summary

Adds dual-stack IPv6 support for WireGuard and AmneziaWG across config parsing/generation, self-hosted setup, desktop activation, platform routing/firewall handling, Android, and Apple NetworkExtension paths.

IPv6 client routing is generated only when WG/AWG has a real client IPv6 address and self-hosted container IPv6 egress is available. Otherwise generated configs remain IPv4-only to avoid IPv6 leaks or the previous fake ULA behavior.

Changes

  • Added optional WG/AWG config keys:
    • client_ipv6
    • subnet_ipv6_address
    • subnet_ipv6_cidr
  • Added default IPv6 WG/AWG server subnets.
  • Updated native WG import parsing for:
    • dual-stack Address
    • IPv6 AllowedIPs
    • IPv6 DNS
    • bracketed IPv6 Endpoint
  • Updated self-hosted WG/AWG generation to:
    • configure IPv4 and IPv6 interface addresses
    • allocate IPv4 and IPv6 peer addresses from existing peers
    • probe container IPv6 egress before issuing IPv6 client routes
    • add guarded IPv6 forwarding and ip6tables NAT/forwarding rules
  • Updated desktop activation to split addresses, routes, DNS, and endpoints by IP family.
  • Updated Linux/macOS/Windows route, firewall, DNS, and endpoint handling for IPv6.
  • Updated Android and Apple NE WG/AWG config paths for dual-stack addresses/routes.
  • Added tests for IPv6 import, JSON round-trips, and desktop activation JSON.

Testing

Passed:

  • Docker Qt/CMake configure
  • Docker build target: test_multiple_imports
  • Docker CTest: MultipleImportsTest
  • Docker Android Kotlin compile:
    • :protocolApi:compileDebugKotlin
    • :wireguard:compileDebugKotlin
  • macOS host Swift syntax parse:
    • WGConfig.swift
    • PacketTunnelProvider+WireGuard.swift
  • git diff --check HEAD~6..HEAD

Notes

Full iOS/macOS NetworkExtension xcodebuild was not run because this host only has Command Line Tools installed, without full Xcode or iOS SDKs. OpenVPN, Xray, and IKEv2 IPv6 behavior is intentionally unchanged in this pass. WireGuard and AmneziaWG/AWG, including direct Amnezia tunnels, gain dual-stack support when a real client IPv6 address and server/container IPv6 egress are available.

ETA: some clarity to avoid confusion.

farhadh added 7 commits May 16, 2026 13:52
Add optional WG/AWG JSON fields for client and server IPv6 addresses, and teach native WireGuard import to parse dual-stack Address, DNS, AllowedIPs, and bracketed IPv6 Endpoint values.
Configure WG/AWG server templates with IPv6 interface addresses, allocate IPv6 peer addresses from existing AllowedIPs, and only issue IPv6 client routes when container IPv6 egress is available.
Split WG/AWG client addresses and endpoints by address family, pass real IPv6 tunnel addresses through activation JSON, and avoid the legacy fake IPv6 ULA route when no client IPv6 exists.
Accept IPv6 split-tunnel routes and AAAA resolutions, preserve IPv6 include/exclude routing, handle IPv6 DNS rules, and keep IPv6 blocked unless a real IPv6 tunnel route is configured.
Pass combined IPv4/IPv6 WG/AWG addresses to mobile clients, filter IPv6 routes when no IPv6 tunnel address exists, and format IPv6 WireGuard endpoints with brackets for Apple NetworkExtension.
Add coverage for bracketed IPv6 endpoints, dual-stack native Address/DNS/AllowedIPs parsing, new JSON field round-trips, and desktop activation JSON IPv6 fields.
Replace newly added IPv6 memcpy calls with explicit fixed-size byte copies and compile-time buffer size checks.
@farhadh
Copy link
Copy Markdown
Author

farhadh commented May 26, 2026

@vkamn @ygurov I know this is a huge PR. I just wanted to add the feature in one go. If it's too big to be reviewed, I'd be happy to turn it into multiple reviewer-friendly PR split that matches the actual dependency order.

@ygurov
Copy link
Copy Markdown
Collaborator

ygurov commented May 29, 2026

Hi @farhadh
Thanks for your PR!
There is a lot of work done here, and I have to check it carefully prior merging. Will do that after the next release cycle, not to introduce any new bugs in the app since we have changed a lot already.
Keep you updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants