I am using curl and I want to randomize the IP curl used with the IPs available for my server.
I need to know the IPs available for my server. Though I can hard code it, is there a PhP program for that?
I am using curl and I want to randomize the IP curl used with the IPs available for my server.
I need to know the IPs available for my server. Though I can hard code it, is there a PhP program for that?
if you are in centos, run this command using php exec()
and it will show you all availables ip interfaces.
ifconfig | grep inet | awk -F 'addr:' '{ print $2} ' | awk -F ' ' '{ print $1 }'
If you need to know your server's external IP address, use this function:
function myIp()
{
$url="simplesniff.com/ip";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}