Is there a way to execute cURL requests through a VPN such as OpenVPN or PPTP?
I'm aware that i can use a proxy, But a VPN is different.
EDIT: JULY 2013
I was getting a few emails on this so I wrapped it all up into a blogpost: http://www.georgiecasey.com/2013/07/26/how-to-use-overplay-and-other-vpns-as-a-curl-proxy/
Yes, but first you've to setup the VPN on a separate interface so your whole server doesn't use the VPN. I'm no OpenVPN expert but I did this with the dev
switch to specify the TUN/TAP virtual network device: dev proxy1
. More info on the OpenVPN man page.
Then use this line of PHP code in your scripts.
curl_setopt($ch, CURLOPT_INTERFACE, "proxy1");
I did this so I could use all the IPs of overplay.net to scrape stuff on my server. These IPs change often so I had a cronjob that pulled the zip file of IPs, created an OpenVPN config file for each IP, started each VPN and put all IPs and interface names in a DB table. Then my scripts just pulled random interface names from the DB and used that in the curl. Worked a treat.
cURL simply uses the operating system's network stack, and does not implement TCP (or lower-level protocols) itself.
Therefore, it works fine with when the operating system is configured to route network communication through a virtual adapter, no matter how that adapter is implemented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With