I have a simple java program that will print the dns name of IP address.
package p1;
import java.net.InetAddress;
public class Main {
public static void main(String[] args) throws Exception {
System.out.println(InetAddress.getByName("201.23.160.63").getHostName());
System.out.println(InetAddress.getByName("191.207.99.75").getHostName());
}
}
the above program displays
- 201-23-160-63.gprs.claro.net.br
- 191.207.99.75
However, on the command line (linux host command), the dns for the two IPs are found. Command line IPs dns
Why does InetAddress.getHostName() not get the dns for IP 191.207.99.75 (191-207-99-75.user.vivozap.com.br) as shown in the command line? or what would be a way to achieve this in java?