# Tutorial: PlexConnect on a Tomato router via entware

**URL:** https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436
**Category:** Apps & Creations
**Created:** [March 1, 2015, 11:29pm UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436 "2015-03-01T23:29:50Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![danofun](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@danofun](https://forums.plex.tv/u/danofun)
#### Post date: [March 1, 2015, 11:29pm UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/1 "2015-03-01T23:29:50Z")

</div>

**Requirements**

- USB stick - 1G or more in size

- USB-capable router running TomatoUSB.

&nbsp;

**Install entware**

Pick a USB stick that you can dedicate to your router since it will be completely erased by the following process.

&nbsp;

**Configure the GUI for entware**

In the web GUI, go to the "USB and NAS-\>USB Support" section and tick the following options:

[x] Core USB Support  
[x] USB 2.0 Support  
[x] USB Storage Support  
[x] Ex2/Ext3 File Systems Support  
[x] Automount

&nbsp;

Paste this text into the "Run after mounting" box:

```
#!/bin/sh
/opt/etc/init.d/rc.unslung start
```

Paste this text into the "Run before unmounting" box:

```
#!/bin/sh
/opt/etc/init.d/rc.unslung stop
sleep 15
for i in `cat /proc/mounts | awk '/ext3/{print($1)}'` ; do
  mount -o remount,ro $i
done 
```

Click the "Save" button and then check the "USB Status" at the bottom of the screen. If your USB stick is mounted, click "Unmount". In subsequent steps, we are going to format the USB stick, so we don't want it mounted.

&nbsp;

Go to the "Administration-\>Scripts-\>Init" page. Paste the following into the "Init" script section:

```
echo "LABEL=ENTWARE /opt ext3 rw,noatime 1 1" >> /etc/fstab
sleep 5
python /opt/PlexConnect/PlexConnect.py
```

Go to the "Administration-\>Scripts-\>Init" page. Paste the following into the "Firewall" script section:

```
iptables -t nat -A PREROUTING -s 192.168.1.111 -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.111 -d 192.168.1.1 -p tcp --dport 443 -j DNAT --to-destination 192.168.1.1:8443 
```

substitute your AppleTV IP address for 192.168.1.111 and your router's IP address for 192.168.1.1

&nbsp;

Click the "Save" button.

&nbsp;

For reference, most of the above is taking from the&nbsp;[entware USB setup](https://github.com/Entware/entware/wiki/USB-Storage-setup#tomatousb-firmware)&nbsp;instructions.

&nbsp;

**Prepare the USB stick**

Plug the USB stick in and ssh to the router. Remember, the next steps will completely erase the USB stick!

&nbsp;

**Find the device name for your USB stick**

Run "fdisk -l" to display all the block devices and their partitions. Here is an example:

```
# fdisk -l

Disk /dev/sdb: 16.2 GB, 16231956480 bytes  
64 heads, 32 sectors/track, 15480 cylinders  
Units = cylinders of 2048 \* 512 = 1048576 bytes

Device Boot Start End Blocks Id System  
/dev/sdb1 1 15480 15851504 83 Linux&nbsp;
```

You can see that the disk /dev/sdb is a 16GB block device. Since there are no other 16GB devices on my router, I can be pretty sure that the 16GB stick that I plugged in is mapped to /dev/sdb.

&nbsp;

**Partition the USB stick**

Use fdisk to delete all the partitions on your USB disk. Then create a single partition spanning the entire drive and set its type to 83 (Linux). Write the partition table and exit fdisk.

&nbsp;

**Format the USB stick**

Replace the /dev/sdb1 below with the path to your newly created partition.

```
mkfs.ext3 -L ENTWARE /dev/sdb1
```

**Perform the entware install**

```
mount /opt
entware-install.sh 
```

REBOOT the router.

&nbsp;

**PlexConnect**

​Now that&nbsp;entware is installed on your router, it is time to add PlexConnect.

&nbsp;

**Install PlexConnect dependancies**

```
opkg update
opkg install git
opkg install python
opkg install python-openssl
opkg install pyload
opkg install nano
opkg install ca-certificates
```

**Create a Symlink for Git**

```
ln -s $(which git) /opt/lib/git-core/git
```

**Install PlexConnect**

```
cd /opt
git clone git://github.com/iBaa/PlexConnect.git
```

**Create Certificates**

```
mkdir /opt/PlexConnect/assets/
mkdir /opt/PlexConnect/assets/certificates/
openssl req -new -nodes -newkey rsa:2048 -out /opt/PlexConnect/assets/certificates/trailers.pem -keyout /opt/PlexConnect/assets/certificates/trailers.key -x509 -days 7300 -subj "/C=US/CN=trailers.apple.com"

openssl x509 -in /opt/PlexConnect/assets/certificates/trailers.pem -outform der -out /opt/PlexConnect/assets/certificates/trailers.cer && cat /opt/PlexConnect/assets/certificates/trailers.key \>\> /opt/PlexConnect/assets/certificates/trailers.pem

chmod -R +x /opt/PlexConnect  
chmod -R 755 /opt/PlexConnect
```

**Settings.cfg**

Run PlexConnect so it will create Settings.cfg

```
cd /opt/PlexConnect
./PlexConnect.py
```

wait few secs and stop PlexConnect with CTRL + C

&nbsp;

use nano to make the following changes to Settings.cfg:

change port\_webserver from 80 to 8080

change port\_ssl from 443 to 8443

change&nbsp;ip\_plexconnect to your router's IP address (192.168.1.1)

enable\_dnsserver = False

enable\_plexconnect\_autodetect = False

```
nano /opt/PlexConnect/Settings.cfg
```

```
[PlexConnect]
enable_plexgdm = True
ip_pms = 192.168.178.10
port_pms = 32400
enable_dnsserver = False
port_dnsserver = 53
ip_dnsmaster = 8.8.8.8
prevent_atv_update = True
enable_plexconnect_autodetect = False
ip_plexconnect = 192.168.1.1
hosttointercept = trailers.apple.com
port_webserver = 8080
enable_webserver_ssl = True
port_ssl = 8443
certfile = ./assets/certificates/trailers.pem
allow_gzip_atv = False
allow_gzip_pmslocal = False
allow_gzip_pmsremote = True
loglevel = Normal
logpath = . 
```

CTRL + X to exit and Y for save.&nbsp;

&nbsp;

**Dnsmasq Custom Configuration**

On your router's Tomato web page, Go to Advanced -\> DHCP/DNS -\> Dnsmasq Custom configuration and enter:

```
address=/trailers.apple.com/192.168.1.1
address=/atv.plexconnect/192.168.1.1 
```

substitute your router's IP address for 192.168.1.1

&nbsp;

REBOOT your router

&nbsp;

**AppleTV**

Now that PlexConnect is installed, we must configure your AppleTV. &nbsp;We are using iptables and dnsmasq to do the redirections so changing your AppleTV's DNS is not necessary.

&nbsp;

1.) Go to the AppleTV settings menu.

2.) Select “General” then scroll the cursor down to highlight “Send Data To Apple” and set to "No".

3.) With "Send Data To Apple" highlighted, press “Play” (not the normal “Select” button) and you will be prompted to add a profile.

Enter:

```
http://trailers.apple.com/trailers.cer
```

ENJOY!

&nbsp;

**How to Update**

To update entware:

```
opkg update
opkg upgrade
```

To update PlexConnect:

```
cd /opt/PlexConnect
git pull 
```

Credit to [dferg](https://gist.github.com/dferg/833aade513965d78b43d)&nbsp;and [shroud](https://forums.plex.tv/topic/71569-tutorial-plexconnect-with-dd-wrt-router/?p=827794) for their contributions to the community.

`Edited by moderation to include ca-certificates as prereq`

---

<div class="post-metadata">

### Author: ![mishanctrl](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mishanctrl/32/230993_2.png) [@mishanctrl](https://forums.plex.tv/u/mishanctrl)
#### Post date: [March 5, 2015, 1:48am UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/2 "2015-03-05T01:48:42Z")

</div>

This seems to work prefectly for me. Thanks for this.

---

<div class="post-metadata">

### Author: ![6th](https://avatars.discourse-cdn.com/v4/letter/6/97f17d/32.png) [@6th](https://forums.plex.tv/u/6th)
#### Post date: [April 8, 2015, 4:54pm UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/3 "2015-04-08T16:54:45Z")

</div>

Thanks for this, saved for future reference

---

<div class="post-metadata">

### Author: ![mishanctrl](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mishanctrl/32/230993_2.png) [@mishanctrl](https://forums.plex.tv/u/mishanctrl)
#### Post date: [May 14, 2015, 4:42pm UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/4 "2015-05-14T16:42:01Z")

</div>

I just tried updating entware and PlexConnect. Entware update when fine but when updating PlexConnect I get the following error:

fatal: Unable to find remote helper for 'https'  
&nbsp;

any ideas why?

---

<div class="post-metadata">

### Author: ![danofun](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@danofun](https://forums.plex.tv/u/danofun)
#### Post date: [May 23, 2015, 4:13pm UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/5 "2015-05-23T16:13:09Z")

</div>

> I just tried updating entware and PlexConnect. Entware update when fine but when updating PlexConnect I get the following error:
> 
> fatal: Unable to find remote helper for 'https'  
> &nbsp;
> 
> any ideas why?

I have just experienced the same issue. &nbsp;It appears Entware has overhauled python. &nbsp;I've update the tutorial to include the necessary changes. &nbsp;All of these steps may not be necessary but it successfully worked for me.

How to upgrade:

- backup&nbsp;/opt/PlexConnect/Settings.cfg

- backup certificates

- remove the folder /opt/PlexConnect

- uninstall the existing packages

- reinstall the necessary packages (python-expat is no longer available/necessary)

- creat a symlink to git

- git clone PlexConnect using git:// instead of https://

- restore certificates

- restored Settings.cfg to /opt/PlexConnect/Settings.cfg

- reboot

Barring another Entware overhaul, future updates should be possible as stated in the above tutorial. &nbsp;Below are the commands outlined above:

```
mkdir /opt/PlexConnect_backup
cp /opt/PlexConnect/Settings.cfg /opt/PlexConnect_backup/Settings.cfg
cp /opt/PlexConnect/assets/certificates/trailers* /opt/PlexConnect_backup/

rm -R /opt/PlexConnect

opkg remove --force-removal-of-dependent-packages git  
opkg remove --force-removal-of-dependent-packages python  
opkg remove --force-removal-of-dependent-packages python-openssl  
opkg remove --force-removal-of-dependent-packages python-expat  
opkg remove --force-removal-of-dependent-packages pyload

opkg update

opkg install git  
opkg install python  
opkg install python-openssl  
opkg install pyload

ln -s $(which git) /opt/lib/git-core/git

cd /opt  
git clone git://github.com/iBaa/PlexConnect.git

cp /opt/PlexConnect\_backup/trailers\* /opt/PlexConnect/assets/certificates/

mv /opt/PlexConnect\_backup/Settings.cfg /opt/PlexConnect/Settings.cfg

rm -R /opt/PlexConnect\_backup

chmod -R +x /opt/PlexConnect  
chmod -R 755 /opt/PlexConnect

reboot
```

---

<div class="post-metadata">

### Author: ![drewbie](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/drewbie/32/6262_2.png) [@drewbie](https://forums.plex.tv/u/drewbie)
#### Post date: [May 23, 2015, 10:13pm UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/6 "2015-05-23T22:13:15Z")

</div>

If your updating why not copy the old certificates and reload them into the certificates folder, that way your atv will already have the correct profile. Just saves a step and confusion

---

<div class="post-metadata">

### Author: ![danofun](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@danofun](https://forums.plex.tv/u/danofun)
#### Post date: [May 27, 2015, 7:35pm UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/7 "2015-05-27T19:35:51Z")

</div>

> If your updating why not copy the old certificates and reload them into the certificates folder, that way your atv will already have the correct profile. Just saves a step and confusion

Great suggestion. &nbsp;Upgrade procedure updated.

---

<div class="post-metadata">

### Author: ![mishanctrl](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mishanctrl/32/230993_2.png) [@mishanctrl](https://forums.plex.tv/u/mishanctrl)
#### Post date: [May 28, 2015, 10:03pm UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/8 "2015-05-28T22:03:40Z")

</div>

Thanks for this.&nbsp; I gave it a try but I must have messed something up trying to do the update. I had to reinstall Entware from scratch.&nbsp; Since TomatoUSB hasn't been updated for move away from googlecode, to install Entware I had to use:

```
wget -O - http://entware.wl500g.info/binaries/mipselsf/installer/entware_install.sh | sh
```

Reinstalling also reminded me that I had to use

```
mount /dev/sda1 /opt
```

instead of just mount /opt . (or sbd1 if that is the case)

Finally, since there may be someone trying to follow this, without knowing how to partition the USB stick, you may want to add instructions for this:

#Partition your usb flash drive  
umount /dev/sda1  
fdisk /dev/sda  
  
Type in the following commands to create a primary partition on your USB Flash drive  
# p # list current partitions  
# o # to delete all partitions  
# n # new partition  
# p # primary partition  
# 1 (one) # first partition  
# # default start block  
# # default end block #use the whole flash drive  
# w # write new partition to disk

Once again, thanks for the great instructions.

---

<div class="post-metadata">

### Author: ![nekton1](https://avatars.discourse-cdn.com/v4/letter/n/b487fb/32.png) [@nekton1](https://forums.plex.tv/u/nekton1)
#### Post date: [June 13, 2015, 3:23am UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/9 "2015-06-13T03:23:55Z")

</div>

Would this work using a Netgear WNR3500Lv2 with Tomato 1.28 firmware "inside" the ISP router connected LAN to LAN with all devices on the same IP range and subnet mask? There is no DHCP anywhere. Currently, the Neatgear is providing VPN access to the ATV so I can watch my Netflix account from overseas. The PMS and PC are currently on a MacMini where the media files reside.

---

<div class="post-metadata">

### Author: ![nekton1](https://avatars.discourse-cdn.com/v4/letter/n/b487fb/32.png) [@nekton1](https://forums.plex.tv/u/nekton1)
#### Post date: [June 13, 2015, 9:30pm UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/10 "2015-06-13T21:30:45Z")

</div>

In this instruction set:

[PlexConnect]

enable\_plexgdm = True  
ip\_pms = 192.168.178.10  
port\_pms = 32400  
enable\_dnsserver = False  
port\_dnsserver = 53  
ip\_dnsmaster = 8.8.8.8  
prevent\_atv\_update = True  
enable\_plexconnect\_autodetect = False  
ip\_plexconnect = 192.168.1.1  
hosttointercept = trailers.apple.com  
port\_webserver = 8080  
enable\_webserver\_ssl = True  
port\_ssl = 8443  
certfile = ./assets/certificates/trailers.pem  
allow\_gzip\_atv = False  
allow\_gzip\_pmslocal = False  
allow\_gzip\_pmsremote = True  
loglevel = Normal  
logpath = .

Is it not necessary to change the IP in red to the IP address of where PMS resides?

---

<div class="post-metadata">

### Author: ![drewbie](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/drewbie/32/6262_2.png) [@drewbie](https://forums.plex.tv/u/drewbie)
#### Post date: [June 13, 2015, 10:14pm UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/11 "2015-06-13T22:14:16Z")

</div>

> In this instruction set:  
> [PlexConnect]  
> enable\_plexgdm = True  
> ip\_pms = 192.168.178.10  
> port\_pms = 32400  
> enable\_dnsserver = False  
> port\_dnsserver = 53  
> ip\_dnsmaster = 8.8.8.8  
> prevent\_atv\_update = True  
> enable\_plexconnect\_autodetect = False  
> ip\_plexconnect = 192.168.1.1  
> hosttointercept = trailers.apple.com  
> port\_webserver = 8080  
> enable\_webserver\_ssl = True  
> port\_ssl = 8443  
> certfile = ./assets/certificates/trailers.pem  
> allow\_gzip\_atv = False  
> allow\_gzip\_pmslocal = False  
> allow\_gzip\_pmsremote = True  
> loglevel = Normal  
> logpath = .  
>   
>   
> Is it not necessary to change the IP in red to the IP address of where PMS resides?

  
Because the line above (enable plex gdm) is true this IP address is ignored.

---

<div class="post-metadata">

### Author: ![nekton1](https://avatars.discourse-cdn.com/v4/letter/n/b487fb/32.png) [@nekton1](https://forums.plex.tv/u/nekton1)
#### Post date: [June 13, 2015, 11:14pm UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/12 "2015-06-13T23:14:25Z")

</div>

Thanks.

---

<div class="post-metadata">

### Author: ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)
#### Post date: [January 8, 2020, 6:53pm UTC](https://forums.plex.tv/t/tutorial-plexconnect-on-a-tomato-router-via-entware/95436/13 "2020-01-08T18:53:28Z")

</div>


