Connect and disconnect VPN on a time

During the evening I use my openVPN connection but during the day (working from home) I need to close the VPN to connect to the corporate VPN.
Is there a programm or a setting to close the VPN on a specific time and start it again after a specific time?

Like: close VPN on 8.30 and start it again on 17.30 o'clock?

thanks! This looks promising!
Is this the correct line:

Add at scheduled tasks add these lines:

# Stop VPN at 8.20 am
20 8 * * 1,2,3,4,5 /etc/init.d/openvpn stop 

# Start VPN at 17.45 (5.45 PM)
45 17 * * 1,2,3,4,5 /etc/init.d/openvpn start

Is it true that the VPN stops at 8.20 am, on monday, tuesday, wednesday, thursday and friday
And starts at 17.45 (5.45 PM) on these days?

1 Like

I think you need to replace 1,2,3,4,5 with 1-5

Also, you can use something like to create and display when your cron entry will be run.


Thanks, so it is like this, correct?

Looks correct to me. I think your system logs should also display an entry every time a CRON entry is run. I'd double check to make sure it stops & starts at the time you've specified and to check if your network is running as expected. Sometimes you might have to restart the CRON service after modifying the crontab to have the new entries take effect (See Startup tab).

1 Like

Why don't you setup dual AP one for VPN and one for passthrough using PBR?

1 Like

Good question. I use a ruckus 300 on my nano pi r2s and didn't check this option if possible.
The vpn is on the nano but i have no idea to divide this vpn

Your current solution would not have a killswitch and you never know if you have data leaks when the VPN should be on but doesn't. Using the nano, you might need a managed switch with vlan or using WiFi dumb AP.

Lookup PBR

1 Like