Custom Search

Sunday, September 30, 2007

Get IP for a host name in VB.Net

' Get the IP addresses for a given domain name

Private Function GetAllIPAddresses(ByVal domainName As String) _
As System.Collections.Specialized.StringCollection

Dim results As New System.Collections.Specialized.StringCollection
Dim hostInfo As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(domainName)

For Each ip As System.Net.IPAddress In hostInfo.AddressList
results.Add(ip.ToString)
Next

Return results
End Function

No comments: