Using the code below I will get all network interfaces which are enabled and functional on the machine.
Private netIntrfc As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
For i As Integer = 0 To netIntrfc.Length - 1
If netIntrfc(i).OperationalStatus = OperationalStatus.Up Then
netDevicesList.Items.Add(netIntrfc(i).Name.ToString)
End If
Next
But my problem is how to get the default one, the one(ethernet adapter) through which user is connected to internet?
I need to change some settings of default(through which user is connected to internet) adapter. settings I change through registry so I could sample add same settings for each network interface but that could cause problems and makes no point then.
EDITED:
For now I have done like code below, so if this can help someone other, but if someone has a better solution or more reliable then send please.
Dim u As UdpClient = New UdpClient(System.Net.Dns.GetHostName, 1)
Dim localAddr As IPAddress = CType(u.Client.LocalEndPoint, IPEndPoint).Address
Private netIntrfc As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
For i As Integer = 0 To netIntrfc.Length - 1
If netIntrfc(i).OperationalStatus = OperationalStatus.Up Then
For Each uni As NetworkInformation.UnicastIPAddressInformation In ipProps.UnicastAddresses
If uni.Address.ToString = localAddr.ToString Then
netDevicesList.Items.Add("DEFAULT: " & netIntrfc(i).Name.ToString)
DEFDEVID = netIntrfc(i).Id.ToString
End If
Next
netDevicesList.Items.Add(netIntrfc(i).Name.ToString)
End If
Next