开发者

Custom IP in CURL [closed]

开发者 https://www.devze.com 2023-03-20 22:08 出处:网络
开发者_运维百科 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form.
开发者_运维百科 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

This doesnt work. Please help!

curl_setopt($ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip", "HTTP_X_FORWARDED_FOR: $ip"));


The REMOTE_ADDR is not user-provided, it's taken from the TCP connection. There's no such thing as a "custom IP".


You can't do it, because the IP address comes from the TCP/IP data packet. The only way to change IP address is using a proxy server


You can't send REMOTE_ADDR as there is no such HTTP header. Even if you could, the response would be received by the specified host (REMOTE_ADDR) and not you. What you are trying to do is called IP Spoofing. You can read more here.


If you don't actually have that IP, don't bother trying as others have said. If however you have that IP on your server, and just want to choose which one of your ips to use on an external connections, you can use curl_setopt(CURLOPT_INTERFACE,'xxx.xxx.xxx.xxx'); (the second argument can be an interface name, an IP address or a host name).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号