Creo que muchos saben como obtener el IP a partir del Nombre del Servidor, si no saben es mediante un simple codigo en CMD de Windows.
Pero es mas interesante programarlo uno mismo...!
Código:
import java.net.*
public class ReverseNameResolution {
/**
* Sole entry point to the class and application.
* @param args Array of String arguments.
*/
public static void main(String[] args) {
String ipAddress = args.length == 0 ? "127.0.0.1" : args[0];
InetAddress inetAddress = null;
// Get the host name given textual representation of the IP address
try {
inetAddress = InetAddress.getByName(ipAddress);
} catch (UnknownHostException e) {
System.out.println("Unknown Host Exception");
e.printStackTrace();
}
// The InetAddress object
System.out.println("InetAddress object " + ipAddress.toString());
// Get machine's host name
System.out.println(
"Host name of " + ipAddress +
" is " + inetAddress.getHostName()
);
// Get machine's canonical host name
System.out.println(
"canonical host name of " + ipAddress +
" is " + inetAddress.getCanonicalHostName()
);
}
}