InetAddress.getByName does not work for a proxy

I am trying to resolve the hostname for my corresponding IP address.

My environment is a macro on the corporate network behind a proxy server that is configured on a .pac file through system settings (automatic proxy settings). So far, everything is working fine, and I can access resources inside and outside my corporate network.

Eliminating hosts on my network works great:   InetAddress.getByName("host.local");

But when I use external host names, I get an UnknownHostException:   InetAddress.getByName("google.com");

produces

Exception in thread "main" java.net.UnknownHostException: google.com
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:850)
    at java.net.InetAddress.getAddressFromNameService(InetAddress.java:1201)
    at java.net.InetAddress.getAllByName0(InetAddress.java:1154)
    at java.net.InetAddress.getAllByName(InetAddress.java:1084)
    at java.net.InetAddress.getAllByName(InetAddress.java:1020)
    at java.net.InetAddress.getByName(InetAddress.java:970)
    at Test.main(Test.java:67)

(I'm a little surprised Inet6AddressImplhere)

As I understand it, InetAddress.getByName uses its own mechanisms for resolving host names. Therefore, I do not think that the error is caused by a missing proxy configuration in java jvm.

But what else could be if everything else works fine?

() :

  • MacBook, ifconfig lo0, gif0, stf0, en0, fw0, en1 → , , ipv4.

  • nslookup google.com ** server can't find google.com: NXDOMAIN

  • Windows Exception

? java?

+5
2

DNS- Interent- (, , , ).

, nslookup .

, , .

+5

, DNS Sun-JVM. , , DNS-. YMMV

System.setProperty("sun.net.spi.nameservice.nameservers", "<my-proxy-ip>");
System.setProperty("sun.net.spi.nameservice.provider.1", "dns,sun");
0

All Articles