I am using openvpn on my own dedicated cloud server (ubuntu). Therefor I created an interface by doing all steps written in this tutorial. Everything works when I am using the terminal as described in the tutorial. Also when I am trying to connect to the interface via curl curl_setopt($ch, CURLOPT_INTERFACE, "tun0");
it works fine. But therefor I have to execute the following statement in the terminal before I run the php script:
openvpn "path/to/my/file.ovpn"
When I want to change the IP address I have to execute the statement above again but with another file.ovpn
.
But I want to change the file.ovpn
in my php script like:
exec('sudo openvpn path/to/my/file.ovpn');
But this isn't working. I always get the error curl error: Could not resolve host: tun0
. So what am I doing wrong? Is this even possible?
For now the configuration files are living in the root folder. So may be it is an authorization / access issue?