Skip to content

DNS cannot resolve IPv6 #129077

@DoctorKrolic

Description

@DoctorKrolic

Description

BCL Dns class APIS doesn't seem to be able to resolve IPv6 even for basic well-known host names

Reproduction Steps

using System.Net;

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Netneeds-author-actionAn issue or pull request that requires more info or actions from the author.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions