views:

2810

answers:

1

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()
+1  A: 

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
Gordon Bell
This code comes back with the IP address of the server. I need the IP address of the remote client.
Jeff