Dns Lookup : DNS « Network « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

   class Program
   {
      static void Main(string[] args)
      {
         if (args.Length != 1)
         {
            Console.WriteLine("Usage: DnsLookup hostname/IP Adddress");
            return;
         }

         IPHostEntry ipHostEntry = Dns.GetHostEntry(args[0]);

         Console.WriteLine("Host: {0}", ipHostEntry.HostName);

         if (ipHostEntry.Aliases.Length > 0)
         {
            Console.WriteLine("\nAliases:");
            foreach (string alias in ipHostEntry.Aliases)
            {
               Console.WriteLine(alias);
            }
         }

         Console.WriteLine("\nAddress(es):");
         foreach (IPAddress address in ipHostEntry.AddressList)
         {
            Console.WriteLine("Address: {0}", address.ToString());
         }

      }
   }








33.2.DNS
33.2.1.DNS Name and Its IPHostEntry
33.2.2.Get DNS host name
33.2.3.Get IP address from host name
33.2.4.Get Host by IP address
33.2.5.Get IPAddress from IPHostEntry
33.2.6.Get IPHostEntry by host name
33.2.7.Resolve a Host name
33.2.8.Get Address List from HostEntry
33.2.9.Use AsyncCallback event to resolve a host name
33.2.10.Dns Lookup