rdegges / ipify-api

A public IP API service.
MIT License
1.71k stars 222 forks source link

api6.ipify.org returns IPv4 address over IPv4 #43

Open scop opened 4 years ago

scop commented 4 years ago

If one tries to request an IPv6 address from api6.ipify.org on a host that has no IPv6 connectivity, api6.ipify.org returns and IPv4 address.

Would be better to prevent that, e.g. simply by making sure api6.ipify.org does not have an A record in DNS, only AAAA. Currently it has both.

Perhaps also add measures against returning an IPv4 address when a v6 one is requested in code, and vice versa.

miquels commented 4 years ago

IMHO, api.ipify.org should have both ipv4 and ipv6 addresses, so that a request from a dual-stack client returns the ipv4 or ipv6 address, so you know what protocol is preferred by the client. Then api4.ipify.org should be v4-only and api6.ipify.org should be v6-only.

Why? Because you can then send requests to api4/api6/api at the same time in parallel, with a small timeout, and from the results you know a) if the client supports ipv4 and what its v4 address is, b) if the client supports ipv6 and what is v6 address is and c) what the preferred protocol is if both are supported.

NiKiZe commented 2 years ago

From the IPv6 section on https://www.ipify.org/

Oct 1, 2020 the A record for api6.ipify.org will be removed to make the subdomain only for IPv6 requests. For universal access please use api64.ipify.org.