[GH-ISSUE #3153] Windows XRay selects disconnected adapter with stale default gateway #1464

Open
opened 2026-10-14 03:42:57 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @mmodrive on GitHub (Sep 11, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3153

Environment:

  • AmneziaVPN 5.0.1.5
  • Windows 11 build 26200
  • XRay core 26.7.28
  • Active Ethernet connection
  • Disconnected Wi-Fi adapter retaining an IPv4 address and default route

Problem:
XRay appears connected, but DNS resolution and web browsing fail. An Android client using the same server works correctly.

Observed diagnostics:

  • The tun2 adapter is created successfully at 10.33.0.2.
  • DNS servers 1.1.1.1 and 1.0.0.1 are assigned to tun2.
  • TCP/443 connections through tun2 succeed.
  • UDP/53 requests through tun2 time out.
  • TCP/53 requests through tun2 fail or are closed.
  • tun2 reports traffic with no adapter packet errors or discarded packets.
  • Authenticated requests directly through Amnezia's embedded SOCKS/XRay endpoint fail after successful SOCKS authentication.
  • A server-side packet capture receives the Windows XRay connection but sees no corresponding outbound DNS or web traffic.
  • Server-side TCP and UDP DNS tests through the same VLESS/Reality configuration succeed.
  • The Windows and server XRay core versions are both 26.7.28.

Root-cause indication:
NetworkUtilities::getGatewayAndIface() enumerates adapters returned by GetAdaptersAddresses() and retains the last adapter containing an IPv4 gateway. It does not check OperStatus and does not select the best route.

Xray::startXray() then uses that interface index with IP_UNICAST_IF for every outbound XRay socket.

The disconnected Wi-Fi adapter still had an IPv4 address and an active default route. Disabling Wi-Fi at the adapter level removed that route and immediately made XRay work.

Steps to reproduce:

  1. Connect Windows to the internet through Ethernet.
  2. Leave a Wi-Fi adapter disconnected but retaining an IPv4 address and default route.
  3. Connect an XRay Reality profile in AmneziaVPN.
  4. Observe that Amnezia reports a connection, but DNS and web browsing fail.
  5. Disable the Wi-Fi adapter with Disable-NetAdapter.
  6. Reconnect AmneziaVPN.
  7. Observe that DNS and web browsing now work.

Expected behavior:
Amnezia should select the active adapter used by the best route to the VPN server.

Suggested fix:
Use GetBestRoute/GetBestRoute2 for the VPN server address, or ignore adapters whose OperStatus is not IfOperStatusUp. Do not select the last adapter returned by GetAdaptersAddresses().

Workaround:
Disable disconnected adapters that retain default gateways.

Originally created by @mmodrive on GitHub (Sep 11, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3153 Environment: - AmneziaVPN 5.0.1.5 - Windows 11 build 26200 - XRay core 26.7.28 - Active Ethernet connection - Disconnected Wi-Fi adapter retaining an IPv4 address and default route Problem: XRay appears connected, but DNS resolution and web browsing fail. An Android client using the same server works correctly. Observed diagnostics: - The tun2 adapter is created successfully at 10.33.0.2. - DNS servers 1.1.1.1 and 1.0.0.1 are assigned to tun2. - TCP/443 connections through tun2 succeed. - UDP/53 requests through tun2 time out. - TCP/53 requests through tun2 fail or are closed. - tun2 reports traffic with no adapter packet errors or discarded packets. - Authenticated requests directly through Amnezia's embedded SOCKS/XRay endpoint fail after successful SOCKS authentication. - A server-side packet capture receives the Windows XRay connection but sees no corresponding outbound DNS or web traffic. - Server-side TCP and UDP DNS tests through the same VLESS/Reality configuration succeed. - The Windows and server XRay core versions are both 26.7.28. Root-cause indication: NetworkUtilities::getGatewayAndIface() enumerates adapters returned by GetAdaptersAddresses() and retains the last adapter containing an IPv4 gateway. It does not check OperStatus and does not select the best route. Xray::startXray() then uses that interface index with IP_UNICAST_IF for every outbound XRay socket. The disconnected Wi-Fi adapter still had an IPv4 address and an active default route. Disabling Wi-Fi at the adapter level removed that route and immediately made XRay work. Steps to reproduce: 1. Connect Windows to the internet through Ethernet. 2. Leave a Wi-Fi adapter disconnected but retaining an IPv4 address and default route. 3. Connect an XRay Reality profile in AmneziaVPN. 4. Observe that Amnezia reports a connection, but DNS and web browsing fail. 5. Disable the Wi-Fi adapter with Disable-NetAdapter. 6. Reconnect AmneziaVPN. 7. Observe that DNS and web browsing now work. Expected behavior: Amnezia should select the active adapter used by the best route to the VPN server. Suggested fix: Use GetBestRoute/GetBestRoute2 for the VPN server address, or ignore adapters whose OperStatus is not IfOperStatusUp. Do not select the last adapter returned by GetAdaptersAddresses(). Workaround: Disable disconnected adapters that retain default gateways.
Author
Owner

@UserBagReporter commented on GitHub (Oct 31, 2026):

I can reproduce this issue on Amnezia Client 5.0.3.0 on Windows 11. Please see the attached report with reproduction steps and diagnostics.

<html>

XRay on Windows fails when switching between Ethernet and Wi-Fi

Amnezia Client: 5.0.3.0
OS: Windows 11
VPN protocol: XRay / VLESS + Reality
VPN server: Just Host

Summary

XRay works correctly when the computer is connected to the Internet via Wi-Fi, but loses Internet connectivity when switching to Ethernet.

The issue appears to be related to incorrect network interface selection when a disconnected Wi-Fi adapter retains a default IPv4 route.

Expected behavior

XRay should work correctly regardless of whether the active Internet connection is Ethernet or Wi-Fi.

The user should not have to manually disable or enable network adapters when switching between connection types.

Actual behavior

  1. When connected via Wi-Fi, XRay connects and Internet access works.

  2. When switching to Ethernet, XRay reports a successful connection, but Internet access stops working.

  3. The Wi-Fi adapter is enabled in Windows but disconnected from the wireless network.

  4. Disabling the Wi-Fi adapter completely using Disable-NetAdapter immediately restores XRay functionality over Ethernet.

  5. Re-enabling the Wi-Fi adapter with Enable-NetAdapter allows Wi-Fi to work normally again.

  6. After re-enabling Wi-Fi, XRay works over Wi-Fi, including after restarting the application and rebooting Windows.

  7. Switching back to Ethernet reproduces the original problem.

Diagnostic information

  • The tun2 virtual interface is created and connected.

  • XRay installs IPv4 routes through the tunnel.

  • TCP connectivity to 1.1.1.1:443 succeeds through the tunnel.

  • DNS requests time out when XRay is affected.

  • HTTPS requests fail when XRay is affected.

  • The same XRay/VLESS configuration works on Android.

  • AmneziaWG works on Windows on the same machine.

Default routes observed during the failure

Windows reports two default IPv4 routes with the same route metric:

Interface | Status | Route metric -- | -- | -- Ethernet | Up | 0 Wi-Fi | Disconnected | 0 Radmin VPN | Up | 9256

The Wi-Fi adapter is disconnected, but its default route remains present.

Reproduction steps

  1. Enable the Wi-Fi adapter in Windows.

  2. Connect to the Internet using Wi-Fi.

  3. Connect using XRay — Internet access works.

  4. Disconnect from Wi-Fi and connect using Ethernet.

  5. Start or reconnect XRay.

  6. XRay reports Connected, but Internet access stops working.

  7. Disable the Wi-Fi adapter in Windows.

  8. Reconnect XRay — Internet access immediately starts working.

Additional notes

The issue appears consistent with reports #3134 and #3153.

A possible cause is that the Windows client selects an interface based on adapter enumeration rather than the actual best route to the VPN server. It may select a disconnected Wi-Fi adapter that still has a default IPv4 gateway.

Requested fix

Please investigate network interface selection in the Windows XRay implementation.

The client should select the appropriate active interface based on the actual routing decision to the VPN server, rather than relying on adapter enumeration or a stale default gateway.

Both Ethernet and Wi-Fi adapters should be allowed to remain enabled simultaneously. Users should be able to switch between Ethernet and Wi-Fi without manually disabling network adapters.

Thank you.

</html>
<!-- gh-comment-id:6542287595 --> @UserBagReporter commented on GitHub (Oct 31, 2026): I can reproduce this issue on Amnezia Client 5.0.3.0 on Windows 11. Please see the attached report with reproduction steps and diagnostics. <html> <body> <!--StartFragment--><h1 data-pm-slice="1 1 []"><span>XRay on Windows fails when switching between Ethernet and Wi-Fi</span></h1><p><strong><span>Amnezia Client:</span></strong><span> 5.0.3.0</span><br><strong><span>OS:</span></strong><span> Windows 11</span><br><strong><span>VPN protocol:</span></strong><span> XRay / VLESS + Reality</span><br><strong><span>VPN server:</span></strong><span> Just Host</span></p><h2><span>Summary</span></h2><p><span>XRay works correctly when the computer is connected to the Internet via Wi-Fi, but loses Internet connectivity when switching to Ethernet.</span></p><p><span>The issue appears to be related to incorrect network interface selection when a disconnected Wi-Fi adapter retains a default IPv4 route.</span></p><h2><span>Expected behavior</span></h2><p><span>XRay should work correctly regardless of whether the active Internet connection is Ethernet or Wi-Fi.</span></p><p><span>The user should not have to manually disable or enable network adapters when switching between connection types.</span></p><h2><span>Actual behavior</span></h2><ol data-spread="false" start="1"><li><p><span>When connected via Wi-Fi, XRay connects and Internet access works.</span></p></li><li><p><span>When switching to Ethernet, XRay reports a successful connection, but Internet access stops working.</span></p></li><li><p><span>The Wi-Fi adapter is enabled in Windows but disconnected from the wireless network.</span></p></li><li><p><span>Disabling the Wi-Fi adapter completely using </span><code dir="ltr"><span>Disable-NetAdapter</span></code><span> immediately restores XRay functionality over Ethernet.</span></p></li><li><p><span>Re-enabling the Wi-Fi adapter with </span><code dir="ltr"><span>Enable-NetAdapter</span></code><span> allows Wi-Fi to work normally again.</span></p></li><li><p><span>After re-enabling Wi-Fi, XRay works over Wi-Fi, including after restarting the application and rebooting Windows.</span></p></li><li><p><span>Switching back to Ethernet reproduces the original problem.</span></p></li></ol><h2><span>Diagnostic information</span></h2><ul data-spread="false"><li><p><span>The </span><code dir="ltr"><span>tun2</span></code><span> virtual interface is created and connected.</span></p></li><li><p><span>XRay installs IPv4 routes through the tunnel.</span></p></li><li><p><span>TCP connectivity to </span><code dir="ltr"><span>1.1.1.1:443</span></code><span> succeeds through the tunnel.</span></p></li><li><p><span>DNS requests time out when XRay is affected.</span></p></li><li><p><span>HTTPS requests fail when XRay is affected.</span></p></li><li><p><span>The same XRay/VLESS configuration works on Android.</span></p></li><li><p><span>AmneziaWG works on Windows on the same machine.</span></p></li></ul><h3><span>Default routes observed during the failure</span></h3><p><span>Windows reports two default IPv4 routes with the same route metric:</span></p> Interface | Status | Route metric -- | -- | -- Ethernet | Up | 0 Wi-Fi | Disconnected | 0 Radmin VPN | Up | 9256 <p><span>The Wi-Fi adapter is disconnected, but its default route remains present.</span></p><h2><span>Reproduction steps</span></h2><ol data-spread="false" start="1"><li><p><span>Enable the Wi-Fi adapter in Windows.</span></p></li><li><p><span>Connect to the Internet using Wi-Fi.</span></p></li><li><p><span>Connect using XRay — Internet access works.</span></p></li><li><p><span>Disconnect from Wi-Fi and connect using Ethernet.</span></p></li><li><p><span>Start or reconnect XRay.</span></p></li><li><p><span>XRay reports Connected, but Internet access stops working.</span></p></li><li><p><span>Disable the Wi-Fi adapter in Windows.</span></p></li><li><p><span>Reconnect XRay — Internet access immediately starts working.</span></p></li></ol><h2><span>Additional notes</span></h2><p><span>The issue appears consistent with reports #3134 and #3153.</span></p><p><span>A possible cause is that the Windows client selects an interface based on adapter enumeration rather than the actual best route to the VPN server. It may select a disconnected Wi-Fi adapter that still has a default IPv4 gateway.</span></p><h2><span>Requested fix</span></h2><p><span>Please investigate network interface selection in the Windows XRay implementation.</span></p><p><span>The client should select the appropriate active interface based on the actual routing decision to the VPN server, rather than relying on adapter enumeration or a stale default gateway.</span></p><p><span>Both Ethernet and Wi-Fi adapters should be allowed to remain enabled simultaneously. Users should be able to switch between Ethernet and Wi-Fi without manually disabling network adapters.</span></p><p><span>Thank you.</span></p><!--EndFragment--> </body> </html>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#1464
No description provided.