I'm developing a PHP application and storing the IP address of the user in a database using $_SERVER['REMOTE_ADDR']
This returns ::1
on a local environment (Apache is set up locally on macOS Sierra).
I understand from previous posts this is because theres is no "round trip" to my ISP. But are there any ways of testing this, i.e. to make sure the code $_SERVER['REMOTE_ADDR']
will return the correct address once the application has been deployed to a live (not local) hosting environment?
The effect I'm after is getting my "real" outbound IP address, as in what would be shown if I visited a site like http://www.whatsmyip.org/
The application I'm building will also show the IP address of the user after it's been stored in a database. So as a second question, if I were to write logic to filter out a local IP from being displayed, should I filter out ::1
and 127.0.0.1
, or are there others too?