Configure OpenWRT/OpenVPN with one file

Hello,

normaly I have to use a other router (OS) but I try to configure OpenWRT on the same way (I hope so much I can switch to a router with openwrt). Maybe I can use this .cfg-file in OpenWRT too?

First, I generate this .cfg-file (on the host "example.org", but I think, how I do this is not important):

OPENVPN_ENABLED=1
OPENVPN_DESCRIPTION=TestRouterTemp
OPENVPN_PROTO=udp
OPENVPN_PORT=1194
OPENVPN_REMOTE_IPADDR=example.org
OPENVPN_PING_INTVL=60
OPENVPN_PING_TOUT=150
OPENVPN_COMP=lzo
OPENVPN_AUTH=tls-mclient
OPENVPN_CA_CERT=LS0tLS1CRUdJTiBDRVJUSUZJQ0FU [...] DRVJUSUZJQ0FURS0tLS0tCg==
OPENVPN_LOCAL_CERT=LS0tLS1CRUdJTiBDRVJUSUZJQ [...] ElGSUNBVEUtLS0tLQo=
OPENVPN_LOCAL_KEY=LS0tLS1CRUdJTiBQUklWQVRF8T [...] otLS0tLUVORCBQUklWQVRFIEtFWS0tLS0tCg==
OPENVPN_EXTRA_OPTS="--float --nobind --script-security 2"
PPP_PING=1
PPP_PING_BIND=1
PPP_PING_IPADDR=172.27.0.1
PPP_PING_SINTVL=900

STARTUP=#!/bin/sh
STARTUP=
STARTUP=iptables -t nat -D PREROUTING -d '10.0.85.0/24' -i tun0 -j NETMAP --to '192.168.1.0/24'
STARTUP=iptables -t nat -I PREROUTING -d '10.0.85.0/24' -i tun0 -j NETMAP --to '192.168.1.0/24'
STARTUP=iptables -t nat -D POSTROUTING -s '192.168.1.0/24' -o tun0 -j NETMAP --to '10.0.85.0/24'
STARTUP=iptables -t nat -I POSTROUTING -s '192.168.1.0/24' -o tun0 -j NETMAP --to '10.0.85.0/24'

Then I login to the router and navigate to Administration -> Configure & Manage -> Command Script and enter the script from above. If the router have a internet connection, he login to the OpenVPN-Server on "example.org". After that, I can connect from "example.org" to the routers webinterface and the network behind the router.

Can I realize this with OpenWRT?

I have also try, to configure a OpenWRT 19.07 with this options manually, but it doesn't work.

I am not sure this format will be recognised by OpenWrt.
You have a couple of options here.
Either you will upload (or create locally on the router) a .conf file and tell openvpn config file where to find it (usually in /etc/openvpn) or in version 19.07 and later you can upload an .ovpn file directly to the Luci.

1 Like