Created
December 18, 2020 13:30
-
-
Save asdaraujo/12ddbca5d0d777d28be9536d4ad0102e to your computer and use it in GitHub Desktop.
Java reverse DNS name resolution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.InetAddress; | |
import java.net.InetSocketAddress; | |
import java.net.UnknownHostException; | |
public class ResolverHelper { | |
public static void main(String[] args) throws UnknownHostException { | |
InetAddress ia = InetAddress.getByName(args[0]); | |
InetSocketAddress isa = new InetSocketAddress(args[0], 12345); | |
System.out.println(ia.getCanonicalHostName()); | |
System.out.println(isa.getAddress().getCanonicalHostName()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment