~Updated June 17, 2015~
I wrote a windows batch file to route plex.tv's current IP address (with various subnet masks to choose from) to your machine's default gateway (e.g. 192.168.2.1). I promise the bat file is safe, just google me and my reputation will speak for itself.
The code is below but I also uploaded a zip containing the bat file and an exe version of the bat file (same as the bat file except runs invisibly). For best results, use windows task scheduler to launch the exe (with highest privileges) as often as you'd like.
This will ensure that even if the IP for plex.tv changes, your setup will automatically route it past your VPN. A list of routed IPs will be saved here:
"%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt"
I'm using PIA and this works perfectly.
Enjoy!
XFlak
P.S.
I forgot to mention. Check out my other projects at https://xflak40.wordpress.com
Tons of good stuff there, as well as donation links should you like my work and be feeling generous
@echo off setlocal set PATH=%SystemRoot%\system32;%SystemRoot%\system32\wbem;%SystemRoot% chcp 437>nulecho VPN Bypass for Plex Media Server
echo by XFlak
echo.::get Default Gateway
ipconfig|findstr /I /C:“Default Gateway”|findstr /I /C:“1” >"%temp%\gateway.txt"
set /p gateway= <"%temp%\gateway.txt"
set gateway=%gateway:*: =%
::echo %gateway%
::If gateway is detected incorrectly, override it by uncommenting the below like (delete : and input your correct gateway
::set gateway=192.168.2.1echo Getting plex.tv current IP addresses…
echo.
echo Note: Log of plex.tv’s routed IP’s saved here:
echo %userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt
echo.
nslookup “plex.tv”|findstr /I /V “Server: Address: Name: timeout” >"%temp% emp.txt"
findstr /I /C:" " “%temp% emp.txt” >"%temp%\plex.tv.txt"
echo.cd /d “%temp%”
for /F “tokens=*” %%A in (plex.tv.txt) do call :list %%A
goto:donelist:list
set PlexIP=%*
set PlexIP=%PlexIP:* =%
echo %PlexIP%
if not exist “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt” goto:skipcheckfindstr /I /C:"%PlexIP%" “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt”>nul
IF NOT ERRORLEVEL 1 (echo IP already routed, skipping…) & (goto:EOF)
:skipcheckecho route -p add %PlexIP% mask 255.255.255.255 %gateway%
route -p add %PlexIP% mask 255.255.255.255 %gateway%
echo.
echo %PlexIP% >>"%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt"
goto:EOF:donelist
::clean no longer used IPs
echo.
echo Removing routed IPs no longer used by plex.tv
echo.if exist “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt” del “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt”>nul
if not exist “%userprofile%\AppData\Local\Plex Media Server” goto:doneclean
if not exist “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt” goto:donecleancd /d “%userprofile%\AppData\Local\Plex Media Server”
for /F “tokens=*” %%A in (PermittedPlexIPs.txt) do call :clean %%A
goto:doneclean:clean
set PlexIP=%*
findstr /I /C:"%PlexIP%" “%temp%\plex.tv.txt” >nul
IF ERRORLEVEL 1 goto:removeecho IP still used: %PlexIP%
echo %PlexIP% >>"%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt"
goto:EOF:remove
echo IP no longer used: route delete %PlexIP%
route delete %PlexIP%
goto:EOF:doneclean
if exist “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt” del “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt”>nul
if exist “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt” move /y “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt” “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt”>nulecho.
echo Finished, exiting…
@ping 127.0.0.1 -n 3 -w 1000> nul
exit
edit: code was missing a ">", old version still worked but log only retained latest IP, the 4 people who downloaded the last version may want to redownload the new one
edit2: updated script\attachments on May 12, 2015, it's now more efficient\secure by using nslookup instead of ping and using subnet mask 255.255.255.255 instead of 255.255.0.0. Thanks to John Doe at cutting cords for the suggestions.
edit3: updated on May 20, 2015, now includes a read me, an uninstaller, and multiple versions of the script for different subnet masks. Try them in the following order until you find one that works for you. Warning, the further you get to the bottom of the list the more IPs will bypass your VPN.
255.255.255.255
255.255.255.252
255.255.255.0
255.255.0.0
255.0.0.0
edit4: updated on June 16, 2015, now it removes old IP addresses no longer used by plex.tv from being routed past your VPN. So only the current IP addresses used by plex.tv will bypass your VPN and nothing else.
edit5: minor update, also added version # (v5) and icon to the exe's