Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Garbage" IP address with colons in $_SERVER['REMOTE_ADDR'] for some clients

I have a PHP script sitting on a server that is hit by several different machines at different times throughout the day based on cronjobs that are setup on each machine. I'd like to know the IP of the machines making the request and when it is made by a browser, the following executes successfully:

<?php
  ...
  echo $_SERVER['REMOTE_ADDR'];
  ...
?>

However, when made by CURL or any other command line tool I have attempted to use (lynx included), I end up with the following garbage:

2701:5:4a80:7d:2ee:8eff:5e61:801d

From the investigation I've done, this is a result of Apache not populating the $_SERVER variable for requests received that are made from the command line.

REMOTE ADDR Issue with Cron Job

Anyone know of a way to get command line requests to play nice with the $_SERVER variable or should I go down another route?

like image 805
TMan Avatar asked Sep 24 '12 18:09

TMan


1 Answers

That's not garbage, that is the correct remote address. Someone used IPv6 to access your server.

like image 160
Brad Avatar answered Sep 28 '22 05:09

Brad