Tutorial: PlexConnect with DD-WRT Router

plexconnect

#1

Because of some demand, I thought to write a Tutorial on how to use a DD-WRT to auto-config all AppleTVs in a Network to connect to PlexConnect instead of Apple Trailers.


The Idea behind this is simple: The router intercepts all connections to trailers.apple.com and reroutes them to the PlexConnect server.

To achive this, first male shure, that PlexConnect works in the traditional way, with manually configuredd AppleTV.


Then, in DD-WRT, click the services-tab and under DNS make shure, that DNSmasq is enabled (should be on by default).

Under additional-options add the following line:


"address=/trailers.apple.com/IP-Address-of-PlexConnect-Server"


After a reboot of the router all should be done. Start your AppleTV, start the Trailers app and enjoy Plex in all it's glory…


I hope some of you guys can use this...

deLoco


P.S. This should be possible with other Routers as well, I don't know any options for other Routers, but we could start a List here…


#2

Thanks but there is already a tutorial, that i have linked to from the wiki:

http://forums.plexapp.com/index.php/topic/70767-using-dnsmasqiptables-to-redirect-dnshttp-traffic-on-tomato/


#3

Okay, I didn't know that…


#4

You can also install plexconnect direcly on the router :)


#5

^^^ ... care to explain how you've been able to do this ?


#6

I can post it later :) But you will need:

usb port in the router

a usb flash drive

version of ddwrt 25400 and above, I got it working on 25760

And what chipset your router have ? 

Look here if you can find it ?

https://downloads.openwrt.org/attitude_adjustment/12.09/

Mine is with ar71xx chipset. wndr3700

Cause you need to install optware, openwrt have been so nice to allow ddwrt to use their package system.


#7

Cool that you can make it a host & instructions (full tutorial) would be great but no fanart is personally a deal breaker for me unless I used it for other users that don't require fanart.


Edit - ah you need a USB port on the router as well, bummer. Still cool for users with the required usb and base version of dd-wrt.


#8
Opps. The links it not complete i pasted this guide here with complete links (wget commands they are shorted down): http://pastebin.com/xfqY3MpW
 
Well I think I got it all here. I am sorry if i repeated myself.
 
Confirmation on this guide:
http://youtu.be/KCkvKRjYH8A
 
All you need is copy paste.
 
You can try this on other routers. But remember change the wget to point to packages compiled for you router.
https://downloads.openwrt.org/attitude_adjustment/12.09/
 
I can confirm its working on WNDR3700V1 (ar71xx based)
 
Should work on all other ar71xx based routers.
https://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/
 
FOR AR71XX Based Routers ONLY. Confirmed working on ddwrt 25408 and 25760 But should work on all newr versions of DDWRT.
 
This will expand your routers storage for PlexConnect and install openwrt's package installer and allow you to install python and all packages listed here: https://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/
 
DO THIS ON YOUR OWN RISK. It is 100% safe :D
 
All changes is made to the USB, we binded to the system dirs. So you can always REMOVE startup script and the USB. Reboot and you are back to before you started this.
 
When you are done with step 10 you can confirm if opkg update is working or not.
If you get "OPKG NOT FOUND" there is no reason to do the rest. Maybe you missed a step, try a newer DDWRT version ?
If it does keep on and follow the last steps where we add a startupscript and the last things.
 
 
 1. You need a USB flash drive. Mine is 800~ MB and software: putty and WinSCP. Google it.
2. Format the USB stick as EXT3, using GPARTED, you can download and run a live version of ubuntu from the CD or from a virtual machine.
2.1
I formated my first partition as:
Filesystem: EXT3
Name: Data
Primary
size: 650 MB
 
and second partition as:
Filesystem: EXT3
Name: System
Primary
size: 150 MB
 
3. Webinterface
Services > USB
Enable:
Core USB Support
USB Storage Support
Automatic Drive Mount
 
4.
Webinterface
Services > NAS
Enable Sambe Sharing
 
5.
Put the USB in the router and restart it.
 
6.
Look in the webinterface that the 2 partitions on your USB drive is mounted as
/tmp/mnt/sda1
/tmp/mnt/sda2
 
7. Putty:
cd /tmp/mnt/sda1 
touch optware.enable 
cd /tmp/mnt/sda2 
mkdir etc opt root bin lib usr 
touch optware.enable 
chmod 755 etc opt root bin lib usr 
mkdir opt/lib 
chmod 755 opt/lib 
cp -a /etc/* /tmp/mnt/sda2/etc/ 
cp -a /bin/* /tmp/mnt/sda2/bin/ 
cp -a /lib/* /tmp/mnt/sda2/lib/ 
cp -a /usr/* /tmp/mnt/sda2/usr/ 
sleep 5 
mount -o bind /tmp/mnt/sda2/etc /etc 
mount -o bind /tmp/mnt/sda2/bin /bin 
mount -o bind /tmp/mnt/sda2/lib /lib 
mount -o bind /tmp/mnt/sda2/usr /usr 
mount -o bind /tmp/mnt/sda2/opt /jffs
 
8.
cd /tmp 
wget http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/uclibcxx_0.2.4-1_ar71xx.ipk
wget http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/libc_0.9.33.2-1_ar71xx.ipk
wget http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/opkg_618-3_ar71xx.ipk
 
ipkg -d / -force-depends install  uclibcxx_0.2.4-1_ar71xx.ipk
ipkg -d / install libc_0.9.33.2-1_ar71xx.ipk 
ipkg -d / install opkg_618-3_ar71xx.ipk
 
You should see:
Connecting to openwrt. And downloading.
 
9.
cat > /etc/opkg.conf << EOF 
src/gz packages http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/
dest root /opt 
dest ram /opt/tmp 
lists_dir ext /opt/tmp/var/opkg-lists 
EOF    
 
10.
umount /jffs 
mount -o bind /tmp/mnt/sda2/opt  /opt 
mount -o bind /tmp/mnt/sda2/root /tmp/root 
export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib' 
opkg update
 
-You should see af running opkg downloading something and Update list of available packes.
 
IF ITS TELLING YOU OPKG NOT FOUND. Your version of DDWRT does not work with this or you missed a step. Remove the USB drive and format it. And try again, or try a other DDWRT version or skip this
 
-else keep going.
 
11.
cat > /tmp/mnt/sda2/root/.profile << EOF 
export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib:/opt/usr/local/lib' 
export PATH='/sbin:/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/usr/bin:/usr/sbin:/opt/usr/local/bin' 
export PS1='\[\033[01;31m\]\u@\h \[\033[01;34m\]\w \$ \[\033[00m\]' 
export TERMINFO='/opt/usr/share/terminfo' 
EOF
 
12. Webinterface. Administration > Commands
CHANGE THE 192.168.1.104 to your ATV IP ADDRESS AND 192.168.1.1 TO YOUR ROUTERS:
 
- iptables forward port 80 to 8080 and 443 to 8443, so we still can use the routers webinterface :)
- The rest is to mount our usb on boot. Without we will lose it everytime we reboot the router. 
 
-Change ip's and paste this:
 
#! /bin/sh 
sleep 2
iptables -t nat -A PREROUTING -s 192.168.1.104 -d 192.168.1.1 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.1:8080
iptables -t nat -A PREROUTING -s 192.168.1.104 -d 192.168.1.1 -p tcp --dport 443 -j DNAT --to-destination 192.168.1.1:8443
sleep 10 
 if [ -f /mnt/sda1/optware.enable ]; then 
  if [ -f /mnt/sda2/optware.enable ]; then 
    mount -o bind /tmp/mnt/sda2/bin  /bin 
    mount -o bind /tmp/mnt/sda2/etc  /etc 
    mount -o bind /tmp/mnt/sda2/lib  /lib 
    mount -o bind /tmp/mnt/sda2/opt  /opt 
    mount -o bind /tmp/mnt/sda2/usr  /usr 
    mount -o bind /tmp/mnt/sda2/root /tmp/root 
   sleep 2 
  else 
   exit 
  fi 
 else 
  exit 
 fi 
 
 if [ -d /opt/usr ]; then 
  export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib' 
  export PATH='/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/sbin:/usr/sbin:/usr/bin' 
 else 
  exit 
 fi 
 
13. Reb00t the router.
 
14. Putty:
opkg update
 
-You should see downloading and updated list.
 
15.
cd /tmp
wget http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/libc_0.9.33.2-1_ar71xx.ipk
opkg install libc_0.9.33.2-1_ar71xx.ipk
 
-And you are done with installing optware (opkg)
 
16.
Now:
opkg install python
opkg install python-openssl
opkg install python-expat
opkg install nano
 
WinSCP:
Transfer PlexConnect with the certificates to /tmp/root/
 
Putty:
chmod -R +x /tmp/root/PlexConnect
chmod -R 755 /tmp/root/PlexConnect
 
-run plexconnect so it will create Settings.cfg
cd /tmp/root/PlexConnect
./PlexConnect.py
 
-wait few secs and stop it with
CTRL + C
nano /tmp/root/PlexConnect/Settings.cfg
Change: 
Port 80 and 443 to 8080 and 8443
enable_dnsserver = False
enable_plexconnect_autodetect = False
 
-And change 192.168.1.1 to your routers lan IP
ip_plexconnect = 192.168.1.1 
CTRL + X and y for save. 
-Webinterface
Services > Services
Change 192.168.1.1 to routers IP and add this to the "Additional DNSMASQ Options"
address=/trailers.apple.com/192.168.1.1
address=/atv.plexconnect/192.168.1.1
 
And you are done.
 
Let me know if you got any questions. And share your result.

#9

When trying to reach downloads.openwrt.org it takes forever, then I get an Operation timed out message. Can't connect to remote host. Seems as though the issue is the wget will not allow downloads from HTTPS sites. The links you gave in the tutorial are not working, as the files are on an HTTPS site, which means no wget.