tags:

views:

103

answers:

1

I'm doing the following to lookup an Internet address. It fails specifically on Solaris machines that have IPv6 nameservers in the resolv.conf. Works fine on Windows machines that have IPv6 nameservers and on IPv4 only Solaris machines. From the error returned it appears that the Java "getAttributes" line is failing internally (somewhere deep) with a parsing problem when presented with an IPv6 nameserver. My question is, "is there a way to do this better that works properly on Solaris when IPv6 is in use?"

InetAddress localhost=InetAddress.getLocalHost();
ipAddress=localhost.getHostAddress();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
DirContext ictx = new InitialDirContext(env);
Attributes attrs=ictx.getAttributes("blah.test.fakedomain", new String[] { "A" });
A: 

The base java.net.InetAddress has had IPv6 variants and IPv4 variants since Java 1.4 (per the javadoc).

Sounds like you've got more of a question about com.sun.jndi.dns.DnsContextFactory. What version of Java?

John M
This is J2SE6. Unfortunately, I don't know ahead of time if the machine will be using IPv6 or IPv4 nameservers. Hence the whole point of using the Java library and not rolling my own. :-)
Brian Knoblauch