Get a Domain's list of IP Addresses - August 2010

If you download this tip please consider making a modest donation.

I recently needed to get the IP Addresses associated with a domain name. I searched the web and found some code which I modified and encapsulated in a class module called: cGetIPAddressesUsingDomainName.

The Demo Application

I wrote a VB.Net, Asp.Net, VS2008 application to demonstrate the code:

Domain Name - Enter a domain name then click 'Get IP Addresses'. A list of IP addresses associated with the domain is shown in a table.

Sample Calling Code

Use code similar to this to get the IP Addresses:

Private Sub DoGetIPAddresses()
   
Dim oT As New cTable
    Dim o As New cGetIPAddressesUsingDomainName
    Dim sDomainName As String = ""
    Dim oTxt As TextBox = Me.TableInput.FindControl("txt" & "domain")
    If Not oTxt Is Nothing Then
       
sDomainName = oTxt.Text.Trim
   
End If
    Try
        If
o.GetIPAddressesUsingDomainName(sDomainName) Then
            Me
.TableResults.Controls.Clear()
            oT.StandardTableProperties(
Me.TableResults)
            oT.MessageClear(
Me.TableInput)
           
Dim i As Integer = 0
           
Do While i < o.IpAddr.Length
                AddRow(
Me.TableResults, i + 1, sDomainName, o.IpAddr(i).ToString)
                i += 1
           
Loop
        End
If
    Catch
ex As Exception
        oT.ErrorMessage(
Me.TableInput, Err.Description)
        Me.TableResults.Controls.Clear()
    End Try
End
Sub

Download VB.Net Code

Download the source code by clicking on the zipped file name.

Download - Source Zipped File Size
VS2008 VB Solution GetIPAddressesForDomain.zip 47K

Previous Tip   Tip Index    Next Tip

Home

Updated 2010/09/03