Reputation: 1091
How I can block the DNS Lookup on Curl?
So, I think have two alternatives, there is:
Exemple: curl_setopt($ch, CURLOPT_PROXY, '0.0.0.');
This will work?
Thank everyone. :)
Upvotes: 1
Views: 2710
Reputation: 32232
If you're trying to force a request to a different server than what DNS specifies then you can muck with /etc/hosts
or C:\Windows\System32\drivers\etc\hosts
, OR you can do it purely through cURL by manually setting a host header.
$hostname = 'www.mydomain.com';
$ip = '1.2.3.4';
$proto = 'http';
$request = '/foo/bar/index.php';
$url = sprintf('%s://%s%s', $proto, $ip, $request); // http://1.2.3.4/foo/bar/index.php
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Host: '.$hostname]);
curl_exec($ch);
Upvotes: 3