What's new

Plex media server bypass openVPN

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

BANsOnLn

Occasional Visitor
I had this working for several years and it just recently stopped after I had to reset my router. I thought I had everything set up correctly but I guess not.

Here is my setup:

MacMini: running PLEX
Router: ASUS RT-AC5300 with most recent merlin firmware (384.13)
- Using TORGUARD VPN.

Here is my router config.

VPN Client:
upload_2019-8-7_22-36-56-png.18938

upload_2019-8-7_22-37-52-png.18939


WAN - Virtual Server/Port Forwarding:
upload_2019-8-7_22-39-9-png.18940


Nat-start:
upload_2019-8-7_22-40-7-png.18941


When I go to my MacMini and do a "what is my IP" I get the IP of the VPN which is correct. The problem is when I run PLEX and look at the remote access it is still trying to connect using the VPN IP (which fails to connect) instead of my ISP IP. I can't figure out if I am missing something. When I turn off the VPN PLEX connects using the ISP IP and works correctly. I want the MacMini to route all traffic through the VPN except for the PLEX server traffic which I want to go through the local IP.

Any and all help would be greatly appreciated!
 
I had this working for several years and it just recently stopped after I had to reset my router. I thought I had everything set up correctly but I guess not.

Here is my setup:

MacMini: running PLEX
Router: ASUS RT-AC5300 with most recent merlin firmware (384.13)
- Using TORGUARD VPN.

Here is my router config.

VPN Client:
upload_2019-8-7_22-36-56-png.18938

upload_2019-8-7_22-37-52-png.18939


WAN - Virtual Server/Port Forwarding:
upload_2019-8-7_22-39-9-png.18940


Nat-start:
upload_2019-8-7_22-40-7-png.18941


When I go to my MacMini and do a "what is my IP" I get the IP of the VPN which is correct. The problem is when I run PLEX and look at the remote access it is still trying to connect using the VPN IP (which fails to connect) instead of my ISP IP. I can't figure out if I am missing something. When I turn off the VPN PLEX connects using the ISP IP and works correctly. I want the MacMini to route all traffic through the VPN except for the PLEX server traffic which I want to go through the local IP.

Any and all help would be greatly appreciated!
I'm curious as I have plex as well but don't run it like you it seems....Anyway...if I understand what you want to do.

You want everything on your computer to run through your VPN provider. The exception being any traffic coming to and from Plex? I would assume that you'd have to create a way to separate plex traffic from other traffic. Possibly using port exceptions? You may be able to use this to accomplish your needs. I've been following but can't say I have used it or fully grasp it all.

https://www.snbforums.com/threads/x3mrouting-selective-routing-for-asuswrt-merlin-firmware.57793/
 
I'm curious as I have plex as well but don't run it like you it seems....Anyway...if I understand what you want to do.

You want everything on your computer to run through your VPN provider. The exception being any traffic coming to and from Plex? I would assume that you'd have to create a way to separate plex traffic from other traffic. Possibly using port exceptions? You may be able to use this to accomplish your needs. I've been following but can't say I have used it or fully grasp it all.

https://www.snbforums.com/threads/x3mrouting-selective-routing-for-asuswrt-merlin-firmware.57793/

That is correct. I want the MacMini to appear as if it is connected through the VPN but Plex Media Server running on the MacMini to use the ISP IP. It really is so frustrating because I had to working without any issues until I had to hard reset my router. I briefly looked over the link you sent me and it seems to be a lot more involved then what I had set up before. Hopefully someone can chime in with something.
 
May not be it, but worth a try.

In plex, go to settings-network and reset the (sorry, at work and can't see what it's called exactly) advertised IP. This happened to my father during a reset and Plex wouldn't work on his LAN...IIRC, plex and the router had mismatched IP address and that was the issue. Good luck.
 
Did you check with them if something has changed?

With the way I had it set up, the Plex was not going though the VPN. It was going through my ISP. Again, As of now, when I do a "what's my IP" from the MacMini it shows from the VPN service. All other devices on the network are returning the IP of the ISP. I had it set up where if you went into Plex and looked under remote access if showed the IP of the ISP even though it was on the MacMini that shows the IP from the VPN. This worked flawlessly until yesterday. There must be some rule I am missing not the router. That is the only thing that has changed.
 
Last edited:
Does your VPN provider forward ports?

I confirm TorGuard provides port forwarding, you find the option in the client area "my services"/"Manage/port management". And indeed, you have to specify there which ports on the VPN server has to be forwarded to you.
 
So I got it to work... Here is what I did:

This is how I got mine to work: I think this is all the steps:
Step 1. Setup Remote Access in Plex
used port 32400

Step 2. Forward this port to your Plex Server.

Use the port from step one as both the Port Range and Local Port. Enable Forwarding for "BOTH". Call your service Plex (doesn't really matter about the name).

Login to router administration

WAN -> Virtual Server / Port Forwarding

I added PLEX,32400,(IP OF PLEX SERVER),32400,BOTH


Step 3. SSH into router

Terminal : SSH login@x.x.x.x

CD /

CD / jffs

CD / scripts

touch openvpn-event

nano openvpn-event

Copy the following TXT into the terminal window

Code:


Code:
#!/bin/sh
sleep 10
ip rule del fwmark 0x7000/0x7000 2> /dev/null
ip rule add fwmark 0x7000/0x7000 table 254 prio 9990
ip route flush cache
iptables -t mangle -D PREROUTING -i br0 -p udp -m multiport --sport 32400 -j MARK --set-mark 0x7000/0x7000 2> /dev/null
iptables -t mangle -D PREROUTING -i br0 -p tcp -m multiport --sport 32400 -j MARK --set-mark 0x7000/0x7000 2> /dev/null
iptables -t mangle -A PREROUTING -i br0 -p udp -m multiport --sport 32400 -j MARK --set-mark 0x7000/0x7000
iptables -t mangle -A PREROUTING -i br0 -p tcp -m multiport --sport 32400 -j MARK --set-mark 0x7000/0x7000
iptables -t mangle -D PREROUTING -i br0 -p udp -m multiport --dport 32400 -j MARK --set-mark 0x7000/0x7000 2> /dev/null
iptables -t mangle -D PREROUTING -i br0 -p tcp -m multiport --dport 32400 -j MARK --set-mark 0x7000/0x7000 2> /dev/null
iptables -t mangle -A PREROUTING -i br0 -p udp -m multiport --dport 32400 -j MARK --set-mark 0x7000/0x7000
iptables -t mangle -A PREROUTING -i br0 -p tcp -m multiport --dport 32400 -j MARK --set-mark 0x7000/0x7000
CTRL+X
Y
ENTER


Step 4. Restart OpenVPN Client

Login to router administration

VPN -> OpenVPN Clients

Service state (Turn OFF)

Service state (Turn ON)

VPN -> VPN Status (OpenVPN Client 1 should say connected)





Now from my MacMini when I do a "what's my IP" I get the IP of the VPN service. When I go into Plex it uses the IP address of my ISP and connects successfully.
 
Last edited:
I
That is correct. I want the MacMini to appear as if it is connected through the VPN but Plex Media Server running on the MacMini to use the ISP IP. It really is so frustrating because I had to working without any issues until I had to hard reset my router. I briefly looked over the link you sent me and it seems to be a lot more involved then what I had set up before. Hopefully someone can chime in with something.

I am curious as to the reason you chose to have Plex server connecting throughout the ISP and not VPN since you have it already?
 
So I got it to work... Here is what I did:

This is how I got mine to work: I think this is all the steps:
Step 1. Setup Remote Access in Plex
used port 32400

Step 2. Forward this port to your Plex Server.

Use the port from step one as both the Port Range and Local Port. Enable Forwarding for "BOTH". Call your service Plex (doesn't really matter about the name).

Login to router administration

WAN -> Virtual Server / Port Forwarding

I added PLEX,32400,(IP OF PLEX SERVER),32400,BOTH


Step 3. SSH into router

Terminal : SSH login@x.x.x.x

CD /

CD / jffs

CD / scripts

touch openvpn-event

nano openvpn-event

Copy the following TXT into the terminal window

Code:


Code:
#!/bin/sh
sleep 10
ip rule del fwmark 0x7000/0x7000 2> /dev/null
ip rule add fwmark 0x7000/0x7000 table 254 prio 9990
ip route flush cache
iptables -t mangle -D PREROUTING -i br0 -p udp -m multiport --sport 32400 -j MARK --set-mark 0x7000/0x7000 2> /dev/null
iptables -t mangle -D PREROUTING -i br0 -p tcp -m multiport --sport 32400 -j MARK --set-mark 0x7000/0x7000 2> /dev/null
iptables -t mangle -A PREROUTING -i br0 -p udp -m multiport --sport 32400 -j MARK --set-mark 0x7000/0x7000
iptables -t mangle -A PREROUTING -i br0 -p tcp -m multiport --sport 32400 -j MARK --set-mark 0x7000/0x7000
iptables -t mangle -D PREROUTING -i br0 -p udp -m multiport --dport 32400 -j MARK --set-mark 0x7000/0x7000 2> /dev/null
iptables -t mangle -D PREROUTING -i br0 -p tcp -m multiport --dport 32400 -j MARK --set-mark 0x7000/0x7000 2> /dev/null
iptables -t mangle -A PREROUTING -i br0 -p udp -m multiport --dport 32400 -j MARK --set-mark 0x7000/0x7000
iptables -t mangle -A PREROUTING -i br0 -p tcp -m multiport --dport 32400 -j MARK --set-mark 0x7000/0x7000
CTRL+X
Y
ENTER


Step 4. Restart OpenVPN Client

Login to router administration

VPN -> OpenVPN Clients

Service state (Turn OFF)

Service state (Turn ON)

VPN -> VPN Status (OpenVPN Client 1 should say connected)





Now from my MacMini when I do a "what's my IP" I get the IP of the VPN service. When I go into Plex it uses the IP address of my ISP and connects successfully.

works great. One other configuration change I had to do is configure the same port forward on my ISP modem/bridge.
Otherwise the Plex remote connection would not work. It’s a good solution.
 
Upon entering : touch openvpn-event
I get : Read-only file system
So when I attempt to modify and save I end up with a ReadOnly error.

Is that to be expected?

I am running Merlin LTS fork version 374.43_45ECj9527 by john9527 on RT-N66U
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top