How to make CF_CONNECTING_IP get both IPV4 and IPV6 at the same time?

What is the name of the domain?

ip.im

What is the issue you’re encountering

When the client has both IPV4 and IPV6, CF_CONNECTING_IP can only get IPV6. How can I get both IPV4 and IPV6 at the same time?

You can’t. If the request comes over IPv6, it only comes over IPv6. And if over IPv4, only IPv4.

If you want to capture both IPv4 and IPv6 addresses of the client, you will need elements or scripts on your page that point to additional hostnames, one that has only A records, and one that has only AAAA records.

On Cloudflare that can’t be done with proxied hostnames, except by using a separate zone where you disable IPv6 which is what I do here…
https://cf.sjr.org.uk/tools/connection

1 Like

Thank you for your reply. Can I obtain both IPV4 and IPV6 separately? How can I achieve this? Currently, I use ipv4.ip.im to directly resolve to the server and have disabled Cloudflare’s CDN feature. If I enable the CDN, clients with both IPV4 and IPV6 only get the IPV6 address. I want ipv4.ip.im to have Cloudflare’s CDN enabled and still be able to obtain the IPV4 address.

As I mentioned above, the process I use is…

If client connects over IPv4, that’s it. They likely don’t have public IPv6 access (as clients try IPv6 first) so there’s no IPv6 address to get.
If the client connects over IPv6, use JS to make a connection to another Cloudflare zone which has IPv6 disabled (so the user is forced to IPv4) which will then return the IPv4 address. Watch for cross-origin issues here. You then have both.

Since disabling IPv6 applies to a whole Cloudflare zone and can’t be done just for a subdomain, you need 2 zones on Cloudflare to make this work. Disabliing IPv6 is done using the API, it is no longer available in the dashboard as an option except for Enterprise.

The other option as I said is to not use the proxy and configure your own server the same way and you can just publish non-proxied A records for ipv4.ip.im and non-proxied AAAA records for ipv6.ip.im.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.