Security – Java cannot resolve DNS address from AIX: UnknownHostException

aixconfigurationdomain-name-systemSecurity

I'm having this strange error.

On AIX, I can reach my server from the command line ( using ping / telnet )

But If I try using java I've got UnkownHostException

This is because Java cannot somehow "use" the DNS but I don't know why. If I use the IP address it works fine.

This is my test program.

    import java.net.*;

    public class Test {
            public static void main( String [] args ) throws Exception  {
                    String host = args[0];
                    int port = Integer.parseInt( args[1] );
                    System.out.println("Connecting to: " + host + " at port: " + port );
                    Socket socket = new Socket( host, port );
                    System.out.println("Connected!");
                    socket.close();
                    System.out.println("Closed!");

            }
     }

Is anyone aware of some kind of configuration under AIX that forbids programs ( like java ) to access DNS information?

I ( well the sysadm ) have added my address in /etc/hosts but it doesn't work either.

Thanks in advance

Java version:

Java(TM) 2 Runtime Environment, Standard Edition (build pap32dev-20080315 (SR7))
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 AIX ppc-32 j9vmap3223-20080315 (JIT enabled)

Best Answer

Is IPv6 support at fault? Try setting the system property java.net.preferIPv4Stack=true.

See what InetAddress.getAllByName(), InetAddress.getAllByAddress() return.

Related Topic