Reputation: 4997
How can I get the IP address of my computer (on which my application is running) in vb.net
Thanks Furqan
Upvotes: 1
Views: 6578
Reputation: 23346
See System.Net.DNS.
Something like this should work:
Dim ips As IPAddress() = Dns.GetHostAddresses(Dns.GetHostName())
Dim index As Integer
For Each ip in ips
Console.WriteLine(ip)
Next ip
Upvotes: 2
Reputation: 40346
One way is to use System.Net.Dns.GetHostAddresses
, passing it the empty string. Note that it will give you an array of addresses, this is because a host can have multiple addresses, one for each interface. A common example would be the loopback address (127.0.0.1) and one or more public facing IP addresses (eg 10.10.1.1). If your machine has a specific host name you can use that instead of the empty string.
Upvotes: 0