Sunday 8 May 2011

How to get IP Address of Websites using C#

How to get IP Address of Websites in C# application
In C# with the help of Namespace System.Net.Sockets and System.Net we can build an application through which we can find ID address of the websites.
Program code is given below-
IPHostEntry - Provides a container class for internet host address information .

Dns.GetHostEntry("Hostname")-
Resolve a DNS hostname or IP Address to an System.Net.IPHostEntry instance.

using System;
using System.Net;
using System.Net.Sockets;

class ip
{
     
    public static void Main()
    {
       String HostName ;
       Console.WriteLine("Enter Web Address:");
       HostName = Console.ReadLine();
       Console.WriteLine("Looking up: {0}", HostName);
       IPHostEntry NameToIpAddress;
       NameToIpAddress = Dns.GetHostEntry(HostName);
       int AddressCount = 0;
       foreach (IPAddress Address in NameToIpAddress.AddressList)
       Console.WriteLine("IP Address {0}: {1}", ++AddressCount, Address.ToString());
       Console.ReadLine();
  
        
    }
}
IP Address of Gmail.com
IP Address of Facebook.com
previous

2 comments:

  1. If anyone want to find ip address of any website means try domain to ip converter tool like WhoisXY.com

    ReplyDelete