•      Powered by
 

DNS & IP Lookups in .NET



This is a class how to resolve a computer name to a DNS name and IP address or pipe an IP address and resolve to a DNS name. This in theory could be given a list of computer names and resolves them to their DNS name and IP address.

Public Class DNSLookup
    Private
Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim computer As Object = "Linuxdesktop"
        Dim ipaddy As Object = "192.168.1.107"

        Dim host As IPHostEntry = Dns.Resolve(computer)
  
    Dim ipAddress As IPAddress = host.AddressList(0)

        Dim myIP As IPAddress = ipAddress.Parse(ipaddy)
        Dim myHost As IPHostEntry = Dns.GetHostByAddress(myIP)
        Dim name As IPHostEntry = Dns.Resolve(myHost.HostName)

        Console.WriteLine(host.HostName)
        Console.WriteLine(ipAddress)

        Console.WriteLine(myHost.HostName)
        Console.WriteLine(name.HostName.ToString())

    End Sub
End Class

 

tio

Terms of Use | Privacy Statement ©2005-2006 IISLogs.com. All rights reserved - Powered by IIS7 - info @ www.IIS.net