I am using Linux machine and IP address is 10.32.17.63.
In DNS, I have made an entry for a domain with this IP ie example.com for 10.32.17.63.
when i do ping example.com
, it is giving me IP means DNS is working fine:
ping example.com PING example.com (10.32.17.63) 56(84) bytes of data
in /etc/hosts there is no entry for example.com
Enumeration<NetworkInterface> nets =
NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets)) {
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
System.out.println("IP := "+inetAddress.getHostAddress());
System.out.println("hostname := "+inetAddress.getCanonicalHostName());
}
}
i searched on internet and found that InetAddress do DNS look up as well. In my enviornment, Security Manager is disabled.
But above code is giving me inetAddress.getHostAddress()
: 10.32.17.63 and
inetAddress.getCanonicalHostName()
: 10.32.17.63 .
I was expecting example.com
in inetAddress.getCanonicalHostName().