问题
I am having a strange problem which seems to be a problem of ipv6 vs ipv4 dns names.
I have a real time scraper which runs on my server which runs on ipv6 network. After scraping, this scraper returns some urls to images on a web page via ajax calls and then the images are shown in the browser on my local machine via the links returned by the scraper. But these urls are not resolved on my local network. My local machine does not run on ipv6 network. Also the web page being scraped hosts the images via CDNs so the scraper would return results / links to images based on which machine / location it runs.
As an example:
server scrapes http://www.flipkart.com/it-s-not-bike-0224060872/p/itmczyx5zzktubhy?pid=9780224060875 and returns the following link:
http://img-ipv6.flixcart.com/image/book/8/7/5/it-s-not-about-the-bike-my-journey-back-to-life-275x275-imadarucmnec3hds.jpeg
When I access this image from my local machine which is in another geography then my server (scraper), then it is unable to resolve the link above. Using curl on my local machine it reports:
curl: (7) Failed to connect to 2001:df0:23e:9002::17: Network is unreachable
while doing the same on server downloads the image perfectly.
I'm not sure why should the link to image work in one network but not in another?
回答1:
Obviously img-ipv6.flixcart.com
is supposed to resolve only to an IPv6 address, not to a v4 one: it just has the IPv6 address 2001:df0:23e:9002::17
which you clearly cannot access from your PC.
Over a IPv4 connection, the image has the address http://img7.flixcart.com/image/book/8/7/5/it-s-not-about-the-bike-my-journey-back-to-life-275x275-imadarucmnec3hds.jpeg.
回答2:
The server name img-ipv6.flixcart.com
only has an IPv6 address. It does not have an IPv4 address.
You will only be able to access that hostname on servers that have IPv6 connectivity.
来源:https://stackoverflow.com/questions/11228606/ipv6-dns-name-unresolved-from-ipv4-network