Get the IPv4 of a visitor

Hello,

is there a possibilty to get the real IPv4 (no pseudo) of a visitor in PHP with
$_SERVER['REMOTE_ADDR']or something else?

Currently I mostly get the IPV6 address of the visitor.

Thanks!

But the most of the visitors have both ip-address and I want to get the IPv4 on a case like this.

Can I set that IPv4 should be prefered?

How can I do it?

If there’s IPv6 available on the visitor’s connection, and the Destination is v6 capable, they will use v6 on priority. They don’t access with both IPs, that doesn’t make sense.

The only way to achieve this is to force the browser making a second request which is possible via IPv4 only.

You could also disable v6 here or on your server.

2 Likes

How can I do it?

Some pages like https://meineipinfo.de/ are also able to get both IPs

That way

I have disabled it but I am getting by using $_SERVER['REMOTE_ADDR'] sometimes the IPv6

I have it disabled a few months ago, so that’s why I am wondering… :roll_eyes:

In the Cloudflare dashboard, IPv6 is no longer something you can toggle on and off, it’s always just on. However, if you need to turn off IPv6, you may still do so using the Cloudflare API.

2 Likes

There’s a switch. That’s confusing :wink:

2 Likes

Thank you very much!

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