Schedule VPN Wireguard ON / OFF

Hi all,

I would like to know if it’s possible to schedule a task to enable my VPN (Wireguard) server during lets midnight till 9am everyday. Basically what I want to achieve is to only accept connections in my vpn server during those hours. Thank you!

Yes but you’ll leave your WG Server running 24x7x365. WG’s default port is 51820. I’m working on adapting something from the OpenWrt Wiki for ‘Parental Controls’ for you. It should be possible to just cut access to :51820 for that timeframe via blocking it with the firewall.

Cavets:

  • GL GUI → Applications → Parental Controls doesn’t look like it’ll do the job
  • I am not skilled in firewall configuration
  • You’ll need to install LuCI (GL GUI → System → Advanced Settings)
  • You might ‘break’ your existing firewall config, therefore all connectivity, doing this. Backup your configuration first within LuCI via System → Backup / Flash firmware → Flash Operations → Backup → Generate achieve. Keep that .tar.gz file handy. You can restore it from the same page if you end up needing to reflash & start from scratch.

This closes WG connections during the inverted timeframe:

  1. Navigate to LuCI → Network → Firewall → Traffic Rules.
  2. Click Add and specify:
  • Name: Toggle-WG-VPN-Server
  • Protocol: UDP
  • Source zone: wgserver or wan; preferably wgserver if listed
  • Source port: 51820
  • Destination zone: Any zone
  • Action: reject
  1. On the Time Restrictions tab specify:
  • Week Days: (as you prefer)
  • Start time: 09:00:01
  • Stop time: 23:59:59
  1. Click Save, then Save & Apply.

I would test this by setting the start/stop timeframe to a 1 min window & try streaming a video to your remote WG client/‘guest’ & see if it’s cut after that minute. Maybe downloading a Linux distro’s ISO — or other mutli-GB file — directly from one of your computers in your LAN by your ‘guest’s’ device would be easier. Rymdport makes that trivial.

Assumes firmware 4.2.1-release4

(No warranties either expressed or implied; I’m not responsible if your devices become sentient & fight back from the abuse.)

Modelled from