I am configuring a server to be dual stack, allowing both ipv4 and ipv6. Then, I want to create a php page to show if the client machine is conecting via ipv4, ipv6 or both.
I have tried $_SERVER['REMOTE_ADDR'] and getenvbyhost("REMOTE_ADDR") as well, but it returns only one or another never both.
I also tried the below code
function isIPv6($ip) {
if(filter_var($ip, FILTER_VALIDATE_IP)) {
if(filter_var($ip, FILTER_FLAG_IPV6)) {
//It is IPv6 indeed.
} else {
//It is IPv4
}
} else {
// Not a valid IP
}
}
Is it possible to get both ips from the server?