import java.net.*;
public class DNSLookup {

  public static void main (String args[]) throws UnknownHostException {
    InetAddress someHost;
    byte bytes[];
    int fourBytes[] = new int[4];

    if (args.length == 0) {
      someHost = InetAddress.getLocalHost();
    } else {
      someHost = InetAddress.getByName (args[0]);
    }

    System.out.print ("Host '"+ someHost.getHostName() +"' has address: ");
    bytes = someHost.getAddress();
    for (int i=0; i<4; i++) {
      fourBytes[i] = bytes[i] & 255;
    }

    System.out.println (fourBytes[0] + "." +
                        fourBytes[1] + "." +
                        fourBytes[2] + "." +
                        fourBytes[3]);
  }
}
