Saturday, July 19, 2008


To get DNS IPs we need to import System.Net Namespace. It contains Dns.GetHostByName method, IPHostEntry and IPAddress class.

Create two text boxes with txtDomainName and txtIPs ID respectively and create one button with btnGetIps ID.

Put below code in btnGetIps event

string strIPs = string.Empty;
IPHostEntry ipHE = Dns.GetHostByName(txtDomainName.Text);
IPAddress[] ipAdd = ipHE.AddressList;
foreach (IPAddress ip in ipAdd)
strIPs += ip + ",";
txtIPs.Text = strIPs;
catch (System.Exception ex)

Enter domain name in txtDomainName text box and click btnGetIps.
All the IPs of the domain entered in txtDomainName textbox will appear in txtIPs textbox.

Happy Coding :)

No comments:

Site Meter