Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JRMorris77
Created December 20, 2017 07:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JRMorris77/bd285e6cdd4594c3275eddc842b40e83 to your computer and use it in GitHub Desktop.
Save JRMorris77/bd285e6cdd4594c3275eddc842b40e83 to your computer and use it in GitHub Desktop.
Get True Outgoing IP Address of a Web Server
/*
There are times when you need to find out of the IP address your domain maps to in DNS is the same
as the IP address of your web server's outgoing interface. This is particularly useful when dealing
with APIs such as eNOM. The following just performs a simple query agains http://ipecho.net/plain to
optain your server's outgoing IP. This can be modified with any number of similar services.
*/
$realIP = file_get_contents("http://ipecho.net/plain");
echo $realIP;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment