Skip to content

fix: enable IPv6 detection on Android via UDPv6 probe - #8

Merged
bropines merged 1 commit into
bropines:mainfrom
sailshen:main
Aug 2, 2026
Merged

bropines merged 1 commit into
bropines:mainfrom
sailshen:main

Conversation

@sailshen

Copy link
Copy Markdown

Problem

Android SELinux blocks /proc/net/* and netlink on Android 11+. Termux ifconfig does not show IPv6 addresses. This makes tailscale unable to detect IPv6 on Android Termux devices, forcing all traffic through DERP relays even when the device has public IPv6 connectivity.

Solution

Rewrites fix_android_netmon.go with a three-layer fallback strategy:

  1. anet.Interfaces() — ioctl-based interface discovery, bypasses netlink blocks on Android 11+
  2. /proc/net/if_inet6 — parses kernel IPv6 routing table directly (works on some devices)
  3. UDPv6 outbound probe — net.Dial("udp6", "[DNS]:53") reads source address from LocalAddr(), discovers global IPv6 address without needing any system file access

Result

  • IPv6 address correctly detected via UDPv6 probe when all other methods fail
  • Direct IPv6 peer-to-peer connections established (confirmed: 4ms ping via IPv6 vs Tokyo DERP relay)
  • Fully backward compatible — if all methods fail, v6=false as before

Android SELinux blocks /proc/net/*, netlink, and ifconfig lacks IPv6
on Termux, making tailscale unable to detect IPv6 on the device.

This patch rewrites fix_android_netmon.go with a three-layer approach:
1. anet.Interfaces() (ioctl-based, bypasses netlink blocks)
2. ifconfig per-interface for IPv4 addresses
3. UDPv6 outbound probe to discover global IPv6 address
   when /proc/net/if_inet6 is unavailable

This enables direct IPv6 peer-to-peer connections on Android Termux,
avoiding DERP relay overhead for devices with public IPv6 connectivity.
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@sailshen sailshen closed this Jul 30, 2026
@sailshen sailshen reopened this Jul 30, 2026
@bropines
bropines merged commit 74a5481 into bropines:main Aug 2, 2026
1 check passed
@bropines

bropines commented Aug 2, 2026

Copy link
Copy Markdown
Owner

merged, thx

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