OpenWrt Forum Archive

Topic: OpenVPN client autostart [Solved]

The content of this topic has been archived on 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,
I have two TL-1043ND (with DESIGNATED DRIVER) one is OpenVPN server and one is acting as a OpenVPN client. I need help to get the client to start automatically. Right now I have to start
openvpn client.ovpn
in screen.
I tried to get it to start by putting the files and config file in
/etc/openvpn/

Any help will be much appreciated.

Cheers
Joakim

(Last edited by joakimb on 3 Nov 2016, 20:06)

You'll need to configure /etc/config/openvpn (you can even configure it to use ovpn file) and then you can use /etc/init.d/openvpn to start your connection automatically on boot.

How do I get it to use my working client.ovpn file?

or how do I rewrite
cat /etc/config/openvpn

config openvpn 'myvpn'
    option enabled '0'
    option verb '3'
    option port '1194'
    option proto 'udp'
    option 'dev' 'tun'
    option server '10.8.0.0 255.255.255.0'
    option ca '/etc/openvpn/ca.crt'
    option cert '/etc/openvpn/my-server.crt'
    option key '/etc/openvpn/my-server.key'
    option dh '/etc/openvpn/dh2048.pem'
    option persist_tun '1'
    option persist_key '1'
    option log '/tmp/openvpn.log'
    option ifconfig_pool_persist '/tmp/openvpn-ipp.txt'
    option fast_io 'on'
    option keepalive '10 60'
    option comp_lzo 'adaptive'
    option push 'route 192.168.3.0 255.255.255.0'

with the values from this
cat /etc/openvpn/client/client.ovpn

client
dev tun
proto udp
remote X.Y.Z.W 1194
remote-cert-tls server
resolv-retry infinite
nobind
ca  /etc/openvpn/client/ca.crt
cert  /etc/openvpn/client/my-client.crt
key  /etc/openvpn/client/my-client.key
comp-lzo yes
persist-tun
persist-key
verb 3

Startup script /etc/init.d/openvpn also reads raw conf files /etc/openvpn/*.conf
place your config where and name as it wants from you

Thanks Bolvan!
that was what I needed! :-)

Yes, you should enable OpenVPN in autostart (by

/etc/init.d/openvpn enable

) and to specify *.ovpn file in the config /etc/config/openvpn. You can do it by uci:

uci set openvpn.myvpn=openvpn
uci set openvpn.myvpn.enabled='1'
uci set openvpn.myvpn.config='/etc/openvpn/vpn_openvpn.ovpn'
uci commit

The file should contain following strings:

config openvpn 'myvpn'
    option enabled '1'
    option config '/etc/openvpn/vpn_openvpn.ovpn'

As far as I understood, by default it reads *.conf file, in this case you can omit "option config".
The principal difference is that in your example

option enabled '0'

.

(Last edited by ulmwind on 9 Nov 2016, 15:28)

The discussion might have continued from here.