There is one network adapter, I need to know its local IPv6, in order to send requests from the socket (socket in DualMode mode) through this IP.

The problem is this. When getting a list of local IPs via Dns.GetHostEntry(Dns.GetHostName()).AddressList is issued two! IPv6 addresses. One address is just from the properties of the network card, and the second one is from the virtual Microsoft 6 to 4 tunnel adapter .

What is the address to use for the socket, and why do we need this adapter?

Update:

I tried to send socket requests through both IPv6 local addresses. As a result, the one that is specified in the network adapter settings is idle, and the one that is issued by Microsoft 6 to 4 tunnel adapter is working.

    1 answer 1

    To check IPv6 (and at the same time IPv4) I had to write this method:

     private static bool CheckLocalIPv4_v6(string ip) { using (var socket = new Socket(SocketType.Dgram, ProtocolType.Unspecified)) { try { var endPoint = new IPEndPoint(IPAddress.Parse(ip), 0); var isIPv6 = (endPoint.AddressFamily == AddressFamily.InterNetworkV6) ? true : false; if (isIPv6) socket.DualMode = true; socket.Bind(endPoint); socket.Connect((isIPv6) ? "2001:4860:4860::8888" : "8.8.8.8", 53); return socket.Connected; } catch { return false; } } } 

    ps only works on .NET 4.5 and higher, proof.

    Pps option is better I did not find, if there is something more good - share =)