0

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().

Gyro Gearless
  • 5,131
  • 3
  • 18
  • 14
VJS
  • 2,891
  • 7
  • 38
  • 70
  • 3
    You've verified that DNS is working, but have you verified that [Reverse DNS lookup](https://en.wikipedia.org/wiki/Reverse_DNS_lookup) is working? – Elliott Frisch May 03 '19 at 07:31
  • I have created my local DNS. I am not using public DNS like google DNS. Is this InetAddress API uses my local DNS ? I made local DNS entry in /etc/resolve.conf – VJS May 03 '19 at 10:52
  • You need to add [reverse dns entries](https://www.itworld.com/article/2833006/how-to-setup-reverse-dns-and-ptr-records.html) for your local ip range. – Elliott Frisch May 03 '19 at 16:29

0 Answers0