Skip to content

Instantly share code, notes, and snippets.

@ouaibsky
Created September 28, 2015 20:17
Show Gist options
  • Save ouaibsky/dd2dd6b3f03dffd0aac0 to your computer and use it in GitHub Desktop.
Save ouaibsky/dd2dd6b3f03dffd0aac0 to your computer and use it in GitHub Desktop.
reverse dns
try {
final String ip = "83.231.226.12";//"173.194.40.143";
//InetAddress inetAddr = InetAddress.getByName("192.168.0.255");
InetAddress inetAddr = InetAddress.getByName(ip);
// Get the host name
String hostname = inetAddr.getHostName();
// Get canonical host name
String canonicalHostname = inetAddr.getCanonicalHostName();
printDns();
System.out.println("Hostname: " + hostname);
System.out.println("Canonical Hostname: " + canonicalHostname);
reverse(null);
test2(null);
System.out.println("rev: " + getRevName(ip));
//System.out.println("DNS Hostname: " + getHostName(ip));
} catch (UnknownHostException e) {
System.out.println("Host not found: " + e.getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment