Answer the question
In order to leave comments, you need to log in
How to find out IPv4 from IPv6 in PHP within your server?
$_SERVER[REMOTE_ADDR] returns 2a03:6f00:1::5c35:6074
Would like to know IPv4 though.
Is it possible to find out in PHP by contacting the DNS server?
I want to know the external IP of the server. The fact is that the IP for accessing the server and the IP by which it accesses other servers are different.
maddog670 , Gave a great answer!!::
$content = file_get_contents('http://checkip.dyndns.com/');
preg_match('/Current IP Address: \[?([:.0-9a-fA-F]+)\]?/', $content, $ip);
$serverIP = $ip[1];
Answer the question
In order to leave comments, you need to log in
These are completely different things and you can’t recognize ipv6 from ipv4, and vice versa
Try to make an Ajax request to a site that ONLY listens on ipv4 or ipv6.
And so to find out whether the user supports ipv6 at all, and at the same time both IPs are in the process.
This is true for any services that check the presence and operation of ipv6.
Otherwise, I don't see the point at all.
If in php then so
<?php
echo $_SERVER["REMOTE_ADDR"];
?>
Do you need something like this?
There, when you log in, you can see your current IP address that your provider gave you - https://calcok.com/kompyutery/2.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question