Search code examples
androiddnsipinetaddress

Android alternative to iNetAddress or get it to use another resolver?


We have a situation in our office where the first DNS resolver found by Android doesn't work over wireless (intentional or not, not sure). I'm doing an app to do whois lookups. I need to translate the whois server to IP using the second resolver (I can run the properties, see the two resolvers, figure out which one works). Unfortunately, as far as I can tell, INetAddress only works on the first resolver. Is there a known alternative, workaround, or anything I can use to get the IP address of a domain through a specified resolver? Even dnsjava itself uses INetAddress.

Thanks in advance


Solution

  • dnsjava does not use InetAdress.getByName() or InetAddress.getAllByName().

    Just use it like this:

    System.setProperty("dns.server", "<resolver you want to use>");
    InetAddress addr = Address.getByName("<name>");