Establish VPN-Connection by running an App


#1

Hi,

I have built a custom yocto with openvpn in it. I can establish an connection through the terminal by executing openvpn.
What is the best way to establish an openvpn connection inside of my app?

For example, after an internet connection is established, I would do the following:
popen("/usr/sbin/openvpn /etc/openvpn/client.conf", "r");

This works more or less. Openvpn is being executed, by no connection can be established. I get the output

RESOLVE: Cannot resolve host address: vpn.example.com: Name or service not known
(Address was replaced by “vpn.example.org” for this post).

But if the app is still running, I can establish a connection through the normal terminal again by executing the same command like in the c application.

Has anyone an idea where there could be the problem or how I should establish an vpn connection?