DNS cannot resolve IPv6
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
### Description
BCL `Dns` class APIS doesn't seem to be able to resolve IPv6 even for basic well-known host names
### Reproduction Steps
```cs
using System.Net;
using System.Net.Sockets;
Console.WriteLine(Socket.OSSupportsIPv6); // This prints 'True' on my machine
var addrs = Dns.GetHostAddresses("google.com");
foreach (var addr in addrs)
{
Console.WriteLine(addr);
}
```
### Expected behavior
Same address list as I get via `Resolve-DnsName` powershell command:
```
2a00:1450:4025:800::65
2a00:1450:4025:800::8a
2a00:1450:4025:800::71
2a00:1450:4025:800::66
142.250.109.102
142.250.109.100
142.250.109.113
142.250.109.138
142.250.109.139
142.250.109.101
```
### Actual behavior
Program prints only IPv4 addresses:
```
142.250.120.102
142.250.120.113
142.250.120.139
142.250.120.100
142.250.120.138
142.250.120.101
```
### Regression?
Same behavior on .NET Framework 4.8.1, .NET 8, 10 and 11
### Known Workarounds
I don't think there are any. When I specify `AddressFamily.InterNetworkV6` as the second parameter of `Dns.GetHostAddresses` I get `System.Net.Sockets.SocketException (0x00002AFC)` thrown
### Configuration
.NET Framework 4.8.1, .NET 8, 10 and 11
Windows 11 25H2 (26200.8457) x64, didn't check on other OSes
### Other information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.