This Java tutorial shows how to get the host or domain name by IP address using Java.
To get a host or domain name, you will need to get an instance of InetAddress. In this case, we will provide a string representation of an IP address. Once we have an instance of InetAddresss we can request the host or domain name using the getHostName() method.
NOTE: The getHostName() method may not be able to resolve the host name for the specified IP address. If this occurs, getHostName() will return the IP address.
//Get an instance of InetAddress for the IP address
InetAddress inetAddress = InetAddress.getByName("184.108.40.206");
//Get the host name
String ipAddress = inetAddress.getHostName();
//Print the host name