1

I've come at this problem every way I could think of, but no luck. I need to perform a reverse DNS lookup using an IPv4 address with the InetAddress class in java. I know there are better libraries for this but I have to use InetAddress because it is required for a class I'm taking. The problem is that every time I supply an IP address, say 66.110.98.16, all i get back is the same address input. Here is my code performing the lookup.

symField.setText(
    InetAddress.getByName(
        dquadField.getText()
    )
    .getCanonicalHostName()
);

The symField and dquadField are just a jTextFields. The only thing I can think of is that it is not reaching a DNS service, but my program works in the reverse just fine. Give me some ideas, thanks.

lloiacono
  • 4,714
  • 2
  • 30
  • 46

1 Answers1

1

I've actually resolved the problem. In my case it had to do with the DNS service configured on my PC. I switched it over from my ISP's DNS to Googles Public DNS. After that it is working just fine.

In case someone stumbles across this and needs a similar fix, all you need to do is the following (for Windows only):

1) Go to network and sharing center (found in control panel). 2) Click change adapter settings on the left of the screen. 3) Choose your primary adapter, right click, and choose properties. 4) Find either the IPv4 or v6 in the list, depending on which you would like to use. 5) Click configure for either one. 6) In the DNS field uncheck the obtain automatically option if it is check, otherwise skip this step. 7) Change the primary and secondary DNS to 8.8.8.8 and 8.8.4.4 (order doesn't matter). NOTE*** If your ISP filled out these fields with their own address, it would be a good idea to write them down in case something goes wrong.