You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DnsResolver (and Dns.Resolve*) is now implemented on all Unix-like platforms by the managed stub resolver in DnsResolverPal.Managed.cs, which is compiled for the -unix TFM and therefore also ships on Android.
When DnsResolverOptions.Servers is empty, the managed resolver obtains the system DNS servers from /etc/resolv.conf via ResolvConf.GetNameServers(). Android has no readable resolver configuration, so this returns an empty list and GetServers() falls back to 127.0.0.1:53:
The result is that every query issued by a default-constructed DnsResolver times out on Android.
This is the same underlying gap that makes IPInterfaceProperties.DnsAddresses throw PlatformNotSupportedException on Android (see AndroidIPInterfaceProperties and the corresponding assertion in IPInterfacePropertiesTest_Android.cs).
Note that this only affects the system-configured server path. Callers that supply DnsResolverOptions.Servers explicitly work fine on Android.
Suggested fix
Add an Android-specific source for the system DNS servers, e.g.:
ConnectivityManager.getLinkProperties(activeNetwork).getDnsServers() through the Android interop layer, or
the net.dns1 / net.dns2 system properties via __system_property_get (legacy, unavailable to non-privileged apps on newer API levels), or
android_res_nsend / the NDK resolver API.
Test impact
The network tests in DnsResolverTest are currently gated with PlatformDetection.IsNotAndroid for this reason. DnsResolverLoopbackTest is unaffected because it passes explicit servers, and does run on Android.
Description
DnsResolver(andDns.Resolve*) is now implemented on all Unix-like platforms by the managed stub resolver inDnsResolverPal.Managed.cs, which is compiled for the-unixTFM and therefore also ships on Android.When
DnsResolverOptions.Serversis empty, the managed resolver obtains the system DNS servers from/etc/resolv.confviaResolvConf.GetNameServers(). Android has no readable resolver configuration, so this returns an empty list andGetServers()falls back to127.0.0.1:53:https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.NameResolution/src/System/Net/DnsResolverPal.Managed.cs#L851-L857
The result is that every query issued by a default-constructed
DnsResolvertimes out on Android.This is the same underlying gap that makes
IPInterfaceProperties.DnsAddressesthrowPlatformNotSupportedExceptionon Android (seeAndroidIPInterfacePropertiesand the corresponding assertion inIPInterfacePropertiesTest_Android.cs).Note that this only affects the system-configured server path. Callers that supply
DnsResolverOptions.Serversexplicitly work fine on Android.Suggested fix
Add an Android-specific source for the system DNS servers, e.g.:
ConnectivityManager.getLinkProperties(activeNetwork).getDnsServers()through the Android interop layer, ornet.dns1/net.dns2system properties via__system_property_get(legacy, unavailable to non-privileged apps on newer API levels), orandroid_res_nsend/ the NDK resolver API.Test impact
The network tests in
DnsResolverTestare currently gated withPlatformDetection.IsNotAndroidfor this reason.DnsResolverLoopbackTestis unaffected because it passes explicit servers, and does run on Android.Note
This issue was drafted by GitHub Copilot.