First, add the following controls to your form:
TextBox. Name it as txtHostName
Button. Name it as btnDNSReverseLookup

Add the following Namespace:
using System.Net;
And the function:
string DNSLookup(IPHostEntry iphe)
{
String str;
str = "";
str += "Host Name:\n" + iphe.HostName;
str += "\n\nAliases:\n";
foreach (string alias in iphe.Aliases)
{
str += alias + "\n";
}
str +="\nAddresses:" ;
foreach (IPAddress address in iphe.AddressList)
{
str += "\n"+ address.ToString();
}
return str;
}
And the btnDNSReverseLookup Click Event:
private void btnDNSReverseLookup_Click(object sender, EventArgs e)
{
try
{
IPHostEntry ipHostEntry = Dns.GetHostByAddress(this.txtHostName.Text);
MessageBox.Show( DNSLookup(ipHostEntry));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
You may also see DNS Lookup in C#
Happy Coding!




