Reputation: 8148
I have a Windows forms application running on a terminal server. I need to determine the IP addresses of each client machine.
I found a way to retreive the IP address for computers with DNS entries (example below), but several of my thin clients were set up with static IPs and have no DNS name. Is there a way to determine the IP address of a remote client without having a DNS name?
Dim clientName As String = My.Computer.Network.ClientName
Dim IPHost As Net.IPHostEntry = Net.Dns.Resolve(clientName & "domain.com")
Dim addresses As Net.IPAddress() = IPHost.AddressList
fullIP = addresses(0).ToString()
Upvotes: 0
Views: 8957
Reputation: 13643
To get the primary IP Address, you can use:
System.Net.Dns.GetHostEntry("").AddressList(0).ToString
This may return an IP6 address, in which case you can try to find the IP4 using:
Dim ipentry As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry("")
For i As Integer = 0 To ipentry.AddressList.Count - 1
MsgBox(System.Net.Dns.GetHostEntry("").AddressList(i).ToString)
Next
Upvotes: 1