import java.io.*; 
import java.net.*; 
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 209.139.205.2. 
*/ 
public static void main (String[] args) 
{ 
if ( args.length == 1 ) 
{ 
String domain = args[ 0 ]; 
try 
{ 
InetAddress addr = InetAddress.getByName ( domain); 
System.out.println ( "main IP Address : " + addr.getHostAddress ()) ; 
System.out.println ( "main hostname   : " + addr.getHostName () ); 
System.out.println () ; 

InetAddress[] addrs = InetAddress.getAllByName (domain); 
for ( int i=0 ; i<addrs.length ; i++ ) 
{ 
if ( ! addrs[ i ].equals(addr ) ) 
{ 
System.out.println ( "alt  IP Address : " + addrs[ i].getHostAddress () ); 
System.out.println ( "alt  hostname   : " + addrs[ i].getHostName () ); 
System.out.println () ; 
} 
} 
} 
catch ( UnknownHostException e ) 
{ 
System.err.println ( "Can't detect domain " + args +" : " +e ) ; 
} 
} 
else 
{ 
System.out.println( "need domain or IP on command line e.g. mindprod.com or 209.139.205.2" ); 
} 
} 
} 