NetworkInterface.GetAllNetworkInterfaces() on Android leads to FileNotFoundException ('/etc/resolv.conf')
See original GitHub issueDescription
Hi,
we tried to port our Xamarin.Forms app to MAUI and encountered a bug.
When calling System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() we get an FileNotFoundException On Windows this works.

Callstack
{System.Net.NetworkInformation.NetworkInformationException (0x80004005): Success at System.Net.NetworkInformation.LinuxNetworkInterface.GetLinuxNetworkInterfaces() at System.Net.NetworkInformation.NetworkInterfacePal.GetAllNetworkInterfaces() at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() at Busmonitor.MAUI.MainPageViewModel.Discover() in C:\git\Busmonitor\Busmonitor.MAUI\ViewModels\MainPageViewModel.cs:line 70}
Best regards
Steps to Reproduce
- In MAUI Template add NetworkInterface.GetAllNetworkInterfaces() to Button Handler
- On Executing the code a file System.IO.FileNotFoundException: ‘Could not find file ‘/etc/resolv.conf’.’ get thrown
Version with bug
Preview 10 (current)
Last version that worked well
Preview 10 (current)
Affected platforms
Android
Affected platform versions
Android 10
Did you find any workaround?
no
Relevant log output
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)

Top Related StackOverflow Question
https://github.com/dotnet/runtime/pull/62780
This seems to fix the problem when merged.
After looking at the code you linked I think there is no way this code could ever run on android. The implementation completely relies on parsing the resolv.conf file. Which is not available on android. I think this it is also not available on some linux distros and I am not sure if this is available on iOS.
[https://github.com/dotnet/runtime/blob/b201a16e1a642f9532c8ea4e42d23af8f4484a36/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.cs#L56]
The mono implementation on the other hand seems much better here. [https://github.com/mono/mono/blob/bdd772531d379b4e78593587d15113c37edd4a64/mcs/class/System/System.Net.NetworkInformation/LinuxNetworkInterface.cs#L64]