-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent behaviour using Dns.GetHostAddresses() #36291
Comments
Tagging subscribers to this area: @dotnet/ncl |
.NET cannot manufacture the records and it depends on OS. On Linux, there is plugin architecture and starts with nsswitch.conf. So it possibly depends on ore aspects than just /etc/hosts. It also depends on resolver configuration and your DNS server configuration. For example hosts using DHCP may or may not be automatically added to DNS. When .NET fails, you can try "nslookup name" to see what OS knows about given name. |
@wfurt Debian version is now properly returning the private address. Thank you, and sorry wasting your time with a problem unrelated to dotnet. |
Context
I'm using
Dns.GetHostAddresses()
to list IP addresses of the local computer. Windows and Debian systems are producing inconsistent results.Code
Results
192.168.1.25
is returned. Even if I manually had loopback/localhost entries in the hosts file.127.0.0.1
is returned when entries are set in the hosts file. When entries are removed, the application outputs the following exception:System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 0xFFFDFFFF): Name or service not known
Observations
I was not expecting Windows to ignore hosts file entries while Debian does not. Also, I expected the private address (through DNS resolution) when entries are removed from the hosts file, as it's the behaviour on Windows.
Windows system
Debian system
Related issues
Looking for similar issues, I found #27534 which seems to be closed. Also found #1488 but is related to CI tests so I didn't want to step in.
The text was updated successfully, but these errors were encountered: