Slate Plus (GL-A1300): how to start and stop OpenVPN client at the command line?

Hello,

I have two Glinet routers running OpenWrt 18.x or 19.x based firmware:

GL-MT300N-V2
GL-USB150

To manage these routers, I never connect to the web interface but I use scripts that allow me to send commands remotely from my computers.

Recently I purchased a Slate Plus router (GL-A1300) which works with firmware based on OpenWrt 21.x.
OpenVPN client management is no longer the same, it is very different, there is something called “VPN client instance”. :face_with_spiral_eyes:

What are the commands to start and stop the OpenVPN client with the default ovpn conf file?

To start the OpenVPN client:

Before: uci set glconfig.openvpn.enable='1' && uci commit glconfig && /etc/init.d/startvpn restart
Now   : uci set network.ovpnclient.disabled='0' && uci commit network && some commands (???)

To stop the OpenVPN client:

Before: uci set glconfig.openvpn.enable='0' && uci commit glconfig && /etc/init.d/startvpn stop
Now   : uci set network.ovpnclient.disabled='1' && uci commit network && some commands (???)

To start the OpenVPN client the following command does not work:

uci set network.ovpnclient.disabled='0' && uci commit network && openvpn --config '/etc/openvpn/profiles/67789/Germany2.ovpn'

Thank you in advance for your help. :nerd_face:

Regards

Enable your vpn from the web interface, then issue this command from an ssh:

ps -w

Look at the result you will see the OpenVPN command used to start the tunnel.

@SpitzAX3000 thank you for the tip.
With ps -w I have found the following command:

/usr/sbin/openvpn --syslog ovpnclient --dev ovpnclient --dev-type tun --route-delay 2 --route-noexec --wr

Unfortunately this command isn’t sufficient for etablishing a VPN connection.
On the VPN dashboard, I have the message “The client is starting, please wait…” and nothing happen.

Regards

You’re right! There was recent changes in the latest firmware.

To achieve what you are looking for, please execute:

uci set firewall.ovpnclient.enabled='1'
uci set firewall.ovpnclient2wan.enabled='1'
uci set firewall.lan2ovpnclient.enabled='1'
uci set firewall.guest2ovpnclient.enabled='1'
uci set network.ovpnclient.disabled='0'
ubus -v call network reload && ubus -v call network.interface.ovpnclient up

To verify the interface is up:
ifconfig ovpnclient

And to list all supported methods for the ovpnclient interface:

# ubus -v list network.interface.ovpnclient
'network.interface.ovpnclient' @84a47755
	"up":{}
	"down":{}
	"renew":{}
	"status":{}
	"prepare":{}
	"dump":{}
	"add_device":{"name":"String","link-ext":"Boolean","vlan":"Array"}
	"remove_device":{"name":"String","link-ext":"Boolean","vlan":"Array"}
	"notify_proto":{}
	"remove":{}
	"set_data":{}

The above commands work on my X3000 modem with latest firmware: 0405release1

You may need also to restart the firewall to take effect, although I haven’t tested it:

ubus -v call firewall reload
ubus -v call firewall restart

1 Like

@SpitzAX3000 Thank you very much for the commands. :wink:

After a lot of checking, here the best way I have found for starting and stopping the OpenvPN client on the Slate Plus:

For starting the client:

uci set firewall.@forwarding[0].enabled='0'
uci set firewall.wan_in_conn_mark.enabled='1'
uci set firewall.lan_in_conn_mark_restore.enabled='1'
uci set firewall.out_conn_mark_restore.enabled='1'
uci set firewall.swap_wan_in_conn_mark.enabled='1'
uci set firewall.@forwarding[1].enabled='0'
uci set firewall.ovpnclient.enabled='1'
uci set firewall.ovpnclient2wan.enabled='1'
uci set firewall.lan2ovpnclient.enabled='1'
uci set firewall.guest2ovpnclient.enabled='1'
/etc/init.d/firewall reload
uci set network.ovpnclient.disabled='0'
ubus -v call network reload
ubus -v call network.interface.ovpnclient up

For stopping the client:

uci set network.ovpnclient.disabled='1'
ubus -v call network.interface.ovpnclient down
ubus -v call network reload
uci set firewall.@forwarding[0].enabled='1'
uci set firewall.wan_in_conn_mark.enabled='0'
uci set firewall.lan_in_conn_mark_restore.enabled='0'
uci set firewall.out_conn_mark_restore.enabled='0'
uci set firewall.swap_wan_in_conn_mark.enabled='0'
uci set firewall.@forwarding[1].enabled='1'
uci set firewall.ovpnclient.enabled='0'
uci set firewall.ovpnclient2wan.enabled='0'
uci set firewall.lan2ovpnclient.enabled='0'
uci set firewall.guest2ovpnclient.enabled='0'
/etc/init.d/firewall reload

The following commands do not exist on the Slate Plus:

ubus -v call firewall reload
ubus -v call firewall restart

Regards

1 Like