I want to connect to the URL http://example.net
using curl, but I need to connect with server with IP adress 192.0.43.10
. How I can say to curl which IP adress it must use?
Asked
Active
Viewed 5,274 times
2
-
Correct me, you want to get an IP address by a hostname? Maybe gethostbyname() help you? – Empty Jun 18 '11 at 19:01
-
I took the liberty of replacing test.com with example.net according to RFC 2606. Feel free to revert if that's not what you intended. – phihag Jun 18 '11 at 19:03
-
I don't want to get an IP adress by a hostname. I want to use IP adress without editing hosts file. – Leonid Jun 18 '11 at 19:19
2 Answers
3
$c = curl_init('http://192.0.43.10/u/r/l');
curl_setopt($c, CURLOPT_HTTPHEADER, array('Host: example.net'));
curl_exec($c);

phihag
- 278,196
- 72
- 453
- 469
-
If I want to pass visitor's Ip Address Not server Ip in this case What can I do? – er.irfankhan11 Sep 04 '15 at 06:04
0