Trying to get my IPv4 address gets VirtualBox IPv4

I tried everything to get an IPv4 address ...

Some examples:

Dim s As String = Dns.GetHostEntry(Dns.GetHostName()).AddressList.Where(Function(a As IPAddress) Not a.IsIPv6LinkLocal AndAlso Not a.IsIPv6Multicast AndAlso Not a.IsIPv6SiteLocal).First().ToString()

_

Dim myClientMachineAddressList As IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName())
Dim myClientMachineIP As String = myClientMachineAddressList.AddressList(0).ToString()

_

strHostName = System.Net.Dns.GetHostName()
strIPAddress = System.Net.Dns.GetHostByName(strHostName).AddressList(0).ToString()

_

Dim entry = Dns.GetHostEntry(System.Net.Dns.GetHostName())
    For Each address In entry.AddressList
        If address.AddressFamily = AddressFamily.InterNetwork Then
            Return address.ToString
        End If
    Next

Etc

... But above all, give me VirtualBox IPv4 Like:

Why is this and how can I fix it?

+4
source share
1 answer

Well, I did not find a way to get the ip that I wanted, but I found a way to get all the available ips with their network adapter name. Here is the code in case someone wants to:

First import System.Net.Sockets, System.NetandSystem.Net.NetworkInformation

The code:

Dim lst As New List(Of String)
    For Each adapter As NetworkInterface In NetworkInterface.GetAllNetworkInterfaces
        lst.Add(adapter.Description & ": " & adapter.GetIPProperties.UnicastAddresses(1).Address.ToString)
    Next

lst is a list with all network adapters and their ips

+2
source

Source: https://habr.com/ru/post/1655877/


All Articles