import java.net.InetAddress;
import java.net.UnknownHostException;

public class WhoIs
   {
   /**
   * Find out ip/hostnames given a domain or IP.
   *
   * @param args domain you wish to lookup on the command line:
   * e.g. mindprod.com or 24.87.56.253.
   */
   public static void main (String[] args)
      {
      if ( args.length == 1 )
         {
         String domain = args[0];
         try
            {
            InetAddress addr = InetAddress.getByName ( domain );
            out.println( "main IP Address : " + addr.getHostAddress());
            out.println( "main hostname   : " + addr.getHostName() );
            out.println();

            InetAddress[] addrs = InetAddress.getAllByName ( domain );
            for ( int i=0; i<addrs.length; i++ )
               {
               if ( ! addrs[i].equals( addr ) )
                  {
                  out.println( "alt  IP Address : " + addrs[i].getHostAddress() );
                  out.println( "alt  hostname   : " + addrs[i].getHostName() );
                  out.println();
                  }
               }
            }
         catch ( UnknownHostException e )
            {
            err.println( "Can't detect domain " + args +" : " + e );
            }
         }
      else
         {
         out.println( "need domain or IP on command line e.g. mindprod.com or 24.87.56.253" );
         }
      }
   }