Question

I want to get the content of http://en.wikipedia.org using java.net.URL's openConnection() method.

I find that en.wikiepdia.org has both IPv4 and IPv6 address:

$ host en.wikipedia.org
en.wikipedia.org is an alias for wikipedia-lb.wikimedia.org.
wikipedia-lb.wikimedia.org is an alias for wikipedia-lb.eqiad.wikimedia.org.
wikipedia-lb.eqiad.wikimedia.org has address 208.80.154.225
wikipedia-lb.eqiad.wikimedia.org has IPv6 address 2620:0:861:ed1a::1

How can I access that site using IPv6 address?

Was it helpful?

Solution

-Djava.net.preferIPv6Addresses=true

This jvm argument will work.

OTHER TIPS

IPv6 in Java is transparent and automatic. Just provide an an IPv6 address and you'll be good to go. Also check that your jvm does NOT have the following set to true

-Djava.net.preferIPv4Stack=true

More details here:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top