VPN at certain times


I am new here so please bear with me :slight_smile: The question refers to the Flint Router.

Is there a possibility to connect a client to a Wireguard VPN only at certain times? So for example no VPN from 8am to 8pm and from 8pm to 8am to connect to the vpn?

Thanks in advance!

You can configure timed commands via crontab in LuCI → System → Scheduled Tasks,such as:

0 20 * * * curl -k -d "{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"\",\"wg-client\",\"start\",{\"group_id\":7514, \"peer_id\":2001}],\"id\":1}"
0 8 * * * curl -k -d "{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"\",\"wg-client\",\"stop\",{}],\"id\":1}"

For the values of group_id and peer_id, see the API call issued when opening the VPN on the Web. You can find it by using Ctrl + Shift + I to open the browser developer tools.

This example is for the 4.x firmware.

1 Like

Thanks for the quick and detailed answer!

currently my devices are selectively routed through the VPN using MAC address. I would like to enable time adjustment only for specific devices. Is this possible?

If you are familiar with the http api, you can find the request to modify the MAC list in the same way. Then add the request to the crontab in the same way.

1 Like

unfortunately with it I am not so familiar. Do you have an example when the MAC is e.g. 06:61:3e:ae:cd:d3?

I would be really grateful to you.

Disable VPN for 06:61:3e:ae:cd:d3 in 8 AM, enable VPN for 06:61:3e:ae:cd:d3 in 8 PM. Please you set VPN Proxy Mode is VPN Policy Base on the Client Device.

0 8 * * * curl -k -d "{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"\",\"vpn-policy\",\"set_mac_policy\",{\"default_policy\":1, \"mac_list\":[\"06:61:3e:ae:cd:d3\"]}],\"id\":1}"
0 20 * * * curl -k -d "{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"\",\"vpn-policy\",\"set_mac_policy\",{\"default_policy\":1, \"mac_list\":[]}],\"id\":1}"