Need to delay OVPN Server

Router: GL.iNet GL-MT2500
Openwrt Version: OpenWrt 21.02-SNAPSHOT r15812+879-46b6ee7ffc

I’m utilizing the OVPN relay server due to the inability to port forward, and the regional relay server provides better speeds.

Unfortunately, the tunnel vpn profile I’m using cannot be directly employed on the OVPN Client, as it only forwards traffic. To work around this, I’m using OVPN Client on Luci to tunnel the traffic, as shown in the image below:

However, I’ve encountered an issue when there is a power loss to the router. After power is restored and all services are up, I am unable to connect to the VPN Server. However, I noticed that when I manually switch off and then switch back on the VPN Server, it starts working again

Now, I’m wondering if there’s a way to delay the VPN Server’s startup to address this issue. Is it possible to do so?

To turn off and turn on OpenVPN server, you can use put the following command in /etc/rc.local with some delay.

curl -H 'glinet: 1' -s -k http://127.0.0.1/rpc -d "{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"\",\"ovpn-server\",\"stop\",{}],\"id\":1}"
sleep 5
curl -H 'glinet: 1' -s -k http://127.0.0.1/rpc -d "{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"\",\"ovpn-server\",\"start\",{}],\"id\":1}"

But I failed to reoccur this issue, do you have more setting details?

1 Like

Thank you for the command it works great. I was wondering if you could assist me in creating a script that automatically restarts the Server OVPN whenever the Luci OVPN client gets disconnected and reconnected.

I’ve prepared a profile for you to test on the Luci OVPN client, along with the mapping for the endpoint client. You can access the profile on pastebin via this link: https://pastebin.com/D6bJ07Lz

To ensure proper testing, please modify the endpoint on the
OVPN Client to: gl-net-test.portmap.host,
and set the Port to: 59232.
Also, make sure that the OVPN Server port is also set to: 59232.

Sorry I don’t understand you need this. That server should be there despite what the client’s status.

1 Like

When the internet connection is lost, the Luci OVPN client will automatically disconnect. Once the internet becomes available again, the Luci OVPN client will reconnect. However, during these instances of disconnection and reconnection, I would like the VPN server to restart as well.

@hansome is it possible ?

Sorry that I’m on other bugs and don’t have much time to do that, I think it’s not an easy requirement. You may describe more about the topology, the hard part you encounter, drawing a picture for example. I can check it later.

I’d try setting up watchcat to monitor your OVPN client’s IP:

2 Likes

@bring.fringe18 This will be perfect, Thank you for suggesting. I will look into it.

My pleasure. Feel free to mark the ‘Solution’ to let others know who may stumble upon a similar need in such a scenario.

1 Like

@bring.fringe18 done

1 Like