Everything seems working as I intended, still testing for anything I may have missed.
I found this script reddit by a user name: Scare_norm
The script placed in /jffs/scripts/ as Plex_StaticRoute.sh (note: with extension .sh)
Here is my services-start script , also placed in /jffs/scripts/ , (note: without any extension)
to launch Plex_StaticRoutes.sh at boot and on the top setup cron job to execute every hour
Thanks to john9527
my openvpn-event script , also placed in /jffs/scripts/ , (note: without any extension)
I found on snb forum by user CODYQX4
Will keep the post upto date as I make progress, Thank you RMerlin and this great community. All the credit goes back to the community there is nothing here I can take credit for its all the bits and pieces I found here on the forums.
Port 32400 forwarded to client running plex server in GUI
OpenVPN client setup page
Redirect Internet traffic : Policy Rules,
Block routed clients if tunnel goes down: Yes
I found this script reddit by a user name: Scare_norm
The script placed in /jffs/scripts/ as Plex_StaticRoute.sh (note: with extension .sh)
Code:
#!/bin/sh
logger "Starting Plex static route script..."
#Fetch Current Server Address for plex.tv
DNS1=$(nslookup plex.tv | tail -1 | awk -F " " '{print $3}')
DNS2=$(nslookup plex.tv 8.8.8.8 | tail -2 | awk -F " " '{print $3}' | tail -1)
DNS3=$(nslookup plex.tv 8.8.4.4 | tail -2 | awk -F " " '{print $3}' | tail -1)
DNS4=$(nslookup plex.tv 68.105.28.11 | tail -2 | awk -F " " '{print $3}' | tail -1)
DNS5=$(nslookup plex.tv 68.105.29.11 | tail -2 | awk -F " " '{print $3}' | tail -1)
logger "Grabbing current ipaddresses from plex.tv"
DNS="$DNS1 $DNS2 $DNS3 $DNS4 $DNS5"
UNIQ_IP=$(echo "$DNS" | tr ' ' '\n' | sort -u | tr '\n' ' ')
logger "Current registered ip addresses: $DNS"
for IP in $UNIQ_IP
do
#Create localroute variable to see if route exists
localroute=`route | grep $IP`
#Check if route exists
if [[ -z "$localroute" ]]; then
#route doesn't exist, add route
logger "Route doesn't exist, creating..."
route add -net "$IP" netmask 255.255.255.255 gw `nvram get wan_gateway`
logger "New routes using $IP created"
echo $IP
else
#route exists, hurray
logger "Plex static routes exist. Cool!"
echo "yay"
fi
done
logger "Plex static route script complete."
exit 0
Here is my services-start script , also placed in /jffs/scripts/ , (note: without any extension)
to launch Plex_StaticRoutes.sh at boot and on the top setup cron job to execute every hour
Thanks to john9527
Code:
#!/bin/sh
sleep 4
#Run the script at boot time
/jffs/scripts/Plex_StaticRoute.sh
#Set the script to run again each hour
cru a PlexStaticRoute "0 */1 * * * /jffs/scripts/Plex_StaticRoute.sh"
exit 0
my openvpn-event script , also placed in /jffs/scripts/ , (note: without any extension)
I found on snb forum by user CODYQX4
Code:
#!/bin/sh
# Setup FWMarks
WAN0=200
WAN1=201
VPN1=211
VPN2=212
VPN3=213
VPN4=214
VPN5=215
# Disable Reverse Path Filtering
sleep 10
for i in /proc/sys/net/ipv4/conf/*/rp_filter ; do
echo 0 > $i
done
# Reset Primary WAN Routing Table
ip route flush table wan0
ip route del default table wan0
ip rule del fwmark $WAN0 table wan0
ip rule del fwmark $VPN1 table ovpnc1
ip rule del fwmark $VPN2 table ovpnc2
ip rule del fwmark $VPN3 table ovpnc3
ip rule del fwmark $VPN4 table ovpnc4
ip rule del fwmark $VPN5 table ovpnc5
ip route flush cache
iptables -t mangle -F PREROUTING
# Reset Primary WAN Routing Table Rules
#VPN_LIST="1 2 3 4 5"
VPN_LIST="1"
for VPNID in $VPN_LIST
do
# Copy IP Routing Rules
ip route show table main | grep -Ev ^default | grep -Ev tun1$VPNID | while read ROUTE;
do
ip route add table wan0 $ROUTE
done
# Set Active VPN State
VPN_STATE=$(nvram get "vpn_client"$VPNID"_state")
if [ $VPN_STATE -eq -1 ]
then
nvram set "vpn_client"$VPNID"_state"=2
fi
done
ip route add default table wan0 via $(nvram get wan0_gateway)
ip rule add fwmark $WAN0 table wan0
ip rule add fwmark $VPN1 table ovpnc1
ip rule add fwmark $VPN2 table ovpnc2
ip rule add fwmark $VPN3 table ovpnc3
ip rule add fwmark $VPN4 table ovpnc4
ip rule add fwmark $VPN5 table ovpnc5
ip route flush cache
# Plex Traffic: Bypass VPN
iptables -t mangle -A PREROUTING -i br0 -p tcp --sport 32400 -j MARK --set-mark $WAN0
iptables -t mangle -A PREROUTING -i br0 -p udp --sport 32400 -j MARK --set-mark $WAN0
iptables -t mangle -A PREROUTING -i br0 -p tcp --dport 32400 -j MARK --set-mark $WAN0
iptables -t mangle -A PREROUTING -i br0 -p udp --dport 32400 -j MARK --set-mark $WAN0
# SSH Traffic: Bypass VPN
iptables -t mangle -A PREROUTING -i br0 -p tcp --sport 22 -j MARK --set-mark $WAN0
iptables -t mangle -A PREROUTING -i br0 -p udp --sport 22 -j MARK --set-mark $WAN0
iptables -t mangle -A PREROUTING -i br0 -p tcp --dport 22 -j MARK --set-mark $WAN0
iptables -t mangle -A PREROUTING -i br0 -p udp --dport 22 -j MARK --set-mark $WAN0
# Portforwarding through VPN
iptables -I FORWARD -i tun11 -p udp -d 192.168.2.111 --dport 52525 -j ACCEPT
iptables -I FORWARD -i tun11 -p tcp -d 192.168.2.111 --dport 52525 -j ACCEPT
iptables -t nat -I PREROUTING -i tun11 -p tcp --dport 52525 -j DNAT --to-destination 192.168.2.111:52525
iptables -t nat -I PREROUTING -i tun11 -p udp --dport 52525 -j DNAT --to-destination 192.168.2.111:52525
Will keep the post upto date as I make progress, Thank you RMerlin and this great community. All the credit goes back to the community there is nothing here I can take credit for its all the bits and pieces I found here on the forums.
Port 32400 forwarded to client running plex server in GUI
OpenVPN client setup page
Redirect Internet traffic : Policy Rules,
Block routed clients if tunnel goes down: Yes
Attachments
Last edited: