Server IP - SOAP

We need to provide the IP addresses that SOAP requests will be coming from, to the SOAP server hosts. The servers have many IP addresses however and I can’t work out what numbers to give them, short of giving them everything.

I’ve made test SOAP calls and looked at the headers but there’s no useful data in there. How best can we get the address of the server that is making the SOAP request?


<?php
define(
    'IS_PRODUCTION',
    true
);

if(IS_PRODUCTION){
    error_reporting(0);
    ini_set('display_errors', false);
}else{
    error_reporting(-1);
    ini_set('display_errors', true);
}

$xml = new SimpleXMLElement(
    sprintf(
        'http://checkip.dyndns.com/?rand=&#37;s',
        time()
    ),
    null,
    true
);

if(true === ($xml instanceof SimpleXMLElement)){
    list($ip) = sscanf((string)$xml->body, 'Current IP Address: %s');
    if(null !== $ip){
        header('HTTP/1.1 200 OK');
        header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
        header('Pragma: no-cache');
        echo $ip;
        exit;
    }
}

header('HTTP/1.1 503 Resource Unavailable');
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Pragma: no-cache');
exit;

This will output the IP (Gateway) your server uses to access the internet. Bear in mind it may change, so you may need log it as you go to check for changes.

Nice one, thank you