Using Plex Server with a VPN

Hi all!

running my Plex server on a Synology DS412+ behind an openVPN connection to Private Internet Access, I was also looking for a solution to have Plex bypass the VPN. @JB09 's script (which i adapted to Synology’s needs a little bit) works great when I run it from the terminal, however, running it as a cronjob just won’t work. I’d appreciate any ideas!

Here’s the script:

#!/bin/sh
#PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
#Fetch Current Server Address for plex.tv
DNS="$(dig plex.tv +short) $(dig serienjunkies.org +short)"
UNIQ_IP=$(echo "$DNS" | tr ' ' '
' | sort -u | tr '
' ' ')

for IP in $UNIQ_IP
do
        #Create localroute variable to see if route exists
        localroute=`ip route list table 2| grep $IP`
        #Check if route exists
        if [[ -z "$localroute" ]]; then
                #route doesn't exist, add route
                ip route add "$IP" via 192.168.100.1 dev eth0 table 2
                echo "Route mit der IP "$IP" erfolgreich hinzugefuegt"
                logger "Route mit der IP "$IP" erfolgreich hinzugefuegt"
        else
                #route exists, hurray
                echo "Routen existieren bereits!"
                logger "Routen existieren bereits!"
        fi
done
exit 0

and here’s the relevant crontab line:

*/5	*	*	*	*	root	/opt/skripte/addroutes.sh >> /opt/skripte/cron.log

there’s no output in the cron.log file.

EDIT: I do not know what I did, other than installing this script from jimmybonney.com/articles/manage_crontab_synology/ to manage crontab on Synology using the traditional “crontab” command. Maybe it checked my crontab file for syntax and fixed it. Anyway, cron seems to run the script now and it works great! Thanks again, @JB09 !