On my website, which runs with apache2 on a debian server with an aaa-record, I check with php whether the user uses IPv6 or not. For this I get the IP address of the user with the following code shippet:
if (isset($_SERVER['HTTP_CLIENT_IP'])){ $ip = $_SERVER['HTTP_CLIENT_IP']; }else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){ $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; }else if(isset($_SERVER['HTTP_X_FORWARDED'])){ $ip = $_SERVER['HTTP_X_FORWARDED']; }else if(isset($_SERVER['HTTP_FORWARDED_FOR'])){ $ip = $_SERVER['HTTP_FORWARDED_FOR']; }else if(isset($_SERVER['HTTP_FORWARDED'])){ $ip = $_SERVER['HTTP_FORWARDED']; }else if(isset($_SERVER['REMOTE_ADDR'])){ $ip = $_SERVER['REMOTE_ADDR']; }else{ echo "ERROR"; } This works all totally fine. But sometimes I get an IPv4 addresse even if I have an Ipv6 connection. And this can't be an error of my internet connection because when if visit an ip check website (like this one) it shows me an ipv6 address. I can also ping my server with ping -6 server_ip. So there must be a problem with my aaa-record or with apache2 or maybe with php. I hope someone can help me.