Is it possible to determine programmatically what IP address cURL is using when connecting to a remote server? I have a shared server that I am using cURL on, and I need to send the IP address as part of the request.
The server that I am talking to requires an authentication string that combines the connection IP address and a rotating passcode (eg my $code = SHA1($_SERVER[‘SERVER_ADDR’] . $passcode) gets compared on their end with SHA1($_SERVER[‘REMOTE_ADDR’] . $passcode)). This worked fine when the outgoing connection from cURL was using the same IP as is stored in $_SERVER[‘SERVER_ADDR’], however the IP address used by cURL is now different and rotating periodically.
You can do this to get your public IP before you call:
However:
whatismyip.org(or similar service) actually being running.