Get IPs for a host name





5
Date Submitted Fri. Sep. 8th, 2006 7:05 PM
Revision 1 of 1
Helper jbplou
Tags net | VB.NET
Comments 0 comments
Returns a string collection of IP addresses for a passed in domain name.


    'get ip addresses for a given domain name, example domainName = www.google.com
    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

 

Jeff B

Comments

There are currently no comments for this snippet.

Voting