The following code ...
my $user_agent = LWP::UserAgent->new;
my $request = HTTP::Request->new(GET => $url);
my $response = $user_agent->request($request);
if ($response->is_success) {
print "OK\n";
} else {
die($response->status_line);
}
.. will fail with ..
500 Can't connect to <hostname> (Bad hostname '<hostname>')
.. if the hostname in $url is an IPv6 only address (that is: presence of an AAAA
record, but no A
record).
My questions are:
A
vs. AAAA
) / "prefer-IPv6-over-IPv4" (AAAA
vs. A
)?Right-click your network connection. Select Properties. Scroll to Internet Protocol version 6. Check the Internet Protocol Version 6 (TCP/IPv6) box.
For wired connection through a router, right-click “Ethernet”, and for wireless connection right-click “Wi-Fi”, and then click “Status”. Click “Details”. If you see an IP address for IPv6 within the window marked with a red box, you are connected to the IPv6 network.
To convert Internet Protocol 4 (IPv4) to Internet Protocol 6 (IPv6), perform the following steps. Open the tool: IPv4 to IPv6 converter. Enter any valid IPv4 address, and click on the "Convert to IPv6" button. The tool will process your request and provide you the converted IPv6 address.
It looks like you just need to use Net::INET6Glue::INET_is_INET6. To quote its example:
use Net::INET6Glue::INET_is_INET6;
use LWP::Simple;
print get( 'http://[::1]:80' );
print get( 'http://ipv6.google.com' );
I believe you'll have to change the module to use the IPV6 net module. By default it does not have this enabled: http://eintr.blogspot.com/2009/03/bad-state-of-ipv6-in-perl.html. I don't believe there is something as simple as "prefer-ipv6"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With