Skip to content

Instantly share code, notes, and snippets.

@rkok
Last active November 13, 2023 14:30
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save rkok/2f0adc724b76eceb0c8fdd4a218a0de9 to your computer and use it in GitHub Desktop.
Save rkok/2f0adc724b76eceb0c8fdd4a218a0de9 to your computer and use it in GitHub Desktop.
Restart Synology VPN connection
#!/bin/bash
#######################
# Setup:
# 1. Setup a VPN in the Synology web interface
# 2. Log in via SSH
# 3. Take a look at /usr/syno/etc/synovpnclient/openvpn/ovpnclient.conf
# 4. Find your VPN entry and fill in the variables below.
# ID = the CLIENT ID, shown between square brackets, e.g. "[o123456789]"
# CONFNAME = value of "conf_name"
#
# Usage:
# ./syno-vpn-reconnect.sh
#
#######################
set -e
##########################################################
CONNFILE=/usr/syno/etc/synovpnclient/vpnc_connecting
ID=o123456789 # <-- REPLACE THIS WITH YOUR CLIENT ID
CONFNAME=myclient # <-- REPLACE THIS WITH YOUR CONF NAME
##########################################################
echo "*** Triggering disconnect"
synovpnc kill_client --name=$CONFNAME
echo "*** Waiting 5 seconds"
sleep 5
echo "*** Triggering connect"
echo conf_id=$ID > $CONNFILE
echo conf_name=$CONFNAME >> $CONNFILE
echo proto=openvpn >> $CONNFILE
synovpnc connect --id=$ID
echo "*** Waiting 15 seconds"
sleep 15
echo "*** Should be connected. Dumping VPN status:"
synovpnc get --name=$CONFNAME
@Jos31fr
Copy link

Jos31fr commented Sep 17, 2022

Thanks !

@syrabo
Copy link

syrabo commented Dec 20, 2022

Thanks!

@boyturtle2
Copy link

Thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment