Transmission on AsusWRT routers through Entware-NG

Transmission is a file sharing program.

When you run a torrent, its data will be made available to others by means of upload.

Any content you share is your sole responsibility.

Optware-NG version here

This version works on all supported routers: RT-N16, RT-N66U, RT-AC66U, RT-AC56U, RT-AC68U, RT-AC87U, RT-AC88U, RT-AC3200, RT-AC5300…

1 – Install Entware-NG from here

2 – Install transmission

opkg install transmission-web transmission-daemon-openssl transmission-remote-openssl

3 – Stop transmission

/opt/etc/init.d/S88transmission stop

4 – Backup standard file settings and create a new optimized one:

mv /opt/etc/transmission/settings.json /opt/etc/transmission/settings.json.backup
cat >> /opt/etc/transmission/settings.json << ‘EOF’
{
“alt-speed-down”: 50,
“alt-speed-enabled”: false,
“alt-speed-time-begin”: 540,
“alt-speed-time-day”: 127,
“alt-speed-time-enabled”: false,
“alt-speed-time-end”: 1020,
“alt-speed-up”: 50,
“bind-address-ipv4”: “0.0.0.0”,
“bind-address-ipv6”: “::”,
“blocklist-enabled”: true,
“blocklist-url”: “http://list.iblocklist.com/?list=bt_level1”,
“cache-size-mb”: 2,
“dht-enabled”: true,
“download-dir”: “/tmp/mnt/sda1/Transmission”,
“download-queue-enabled”: true,
“download-queue-size”: 3,
“encryption”: 0,
“idle-seeding-limit”: 180,
“idle-seeding-limit-enabled”: true,
“incomplete-dir”: “/tmp/mnt/sda1/Transmission/Incomplete”,
“incomplete-dir-enabled”: false,
“lazy-bitfield-enabled”: true,
“lpd-enabled”: false,
“message-level”: 2,
“open-file-limit”: 5,
“peer-congestion-algorithm”: “”,
“peer-id-ttl-hours”: 6,
“peer-limit-global”: 80,
“peer-limit-per-torrent”: 30,
“peer-port”: 51413,
“peer-port-random-high”: 65535,
“peer-port-random-low”: 49152,
“peer-port-random-on-start”: false,
“peer-socket-tos”: “default”,
“pex-enabled”: true,
“pidfile”: “/var/run/transmission-daemon.pid”,
“port-forwarding-enabled”: true,
“preallocation”: 1,
“prefetch-enabled”: 1,
“proxy”: “”,
“proxy-auth-enabled”: false,
“proxy-auth-password”: “”,
“proxy-auth-username”: “”,
“proxy-enabled”: false,
“proxy-port”: 80,
“proxy-type”: 0,
“queue-stalled-enabled”: true,
“queue-stalled-minutes”: 300,
“ratio-limit”: 7,
“ratio-limit-enabled”: true,
“rename-partial-files”: true,
“rpc-authentication-required”: true,
“rpc-bind-address”: “0.0.0.0”,
“rpc-enabled”: true,
“rpc-password”: “admin”,
“rpc-port”: 9091,
“rpc-url”: “/transmission/”,
“rpc-username”: “admin”,
“rpc-whitelist”: “*.*.*.*”,
“rpc-whitelist-enabled”: false,
“scrape-paused-torrents-enabled”: true,
“script-torrent-done-enabled”: false,
“script-torrent-done-filename”: “”,
“seed-queue-enabled”: false,
“seed-queue-size”: 10,
“speed-limit-down”: 100,
“speed-limit-down-enabled”: false,
“speed-limit-up”: 100,
“speed-limit-up-enabled”: false,
“start-added-torrents”: true,
“trash-original-torrent-files”: false,
“umask”: 0,
“upload-slots-per-torrent”: 10,
“utp-enabled”: false,
“watch-dir”: “/opt/etc/transmission/watchdir”,
“watch-dir-enabled”: true
}
EOF

Press ENTER
5 –
Start transmission daemon

/opt/etc/init.d/S88transmission start

6 – Open transmission webpage by going to default router ip address and port 9091, ex. 192.168.1.1:9091 (username: admin and password: admin)
The default download folder is on /mnt/sda1/Transmission (will be created automatically with the first downloaded torrent and can be changed editing settings.json file) if your usb disk has a label, change sda1 with the disk label. Be sure transmission-daemon is not running or changes will be overwritten!!!

/opt/etc/init.d/S88transmission stop

7 – With nano you can edit any settings like enable / change username, password:

nano /opt/etc/transmission/settings.json

8 – Save settings with CTRL-O, press ENTER and exit nano with CTRL-X, now start transmission again

/opt/etc/init.d/S88transmission start

9 – Create init-start script for some memory tweaks as suggested by ryzhov_al

nano /jffs/scripts/init-start

#!/bin/sh
echo 524288 > /proc/sys/net/core/rmem_max
echo 524288 > /proc/sys/net/core/wmem_max
echo 8192 > /proc/sys/vm/min_free_kbytes

Save with CTRL-O, press ENTER and exit nano with CTRL-X

Make scripts executable

chmod a+rx /jffs/scripts/*

ACCESS FROM WAN
• If you want to access transmission from WAN like work, school, smartphone, tablet or some other device we need to open the port 9091 but the firmware doesn’t allow port forwarding to the router himself, for that we will use firewall-start script on /jffs partition:

Create firewall rules

nano /jffs/scripts/firewall-start

Paste this lines in terminal

#!/bin/sh

iptables -I INPUT -p tcp –destination-port 9091 -j ACCEPT
iptables -I INPUT -p tcp –destination-port 51413 -j ACCEPT
iptables -I INPUT -p udp –destination-port 51413 -j ACCEPT

Save with CTRL-O / Enter / and exit with CTRL-X

Make scripts executable and apply rules

chmod a+rx /jffs/scripts/*
sh /jffs/scripts/firewall-start

Go to YourWanIp:9091 on preferred internet browser or install Transmission Remote GUI

TransmissionRemoteGUI


SWAP FILE (Highly recommended) is created automatically when installing Entware-NG
If transmission crashes sometimes “without reason”, most probably router goes out of memory and this can be fixed by creating a swap partition but it’s a little bit to complicated for most users and we will create a swap file instead, 512MB is more than enough:

cd /opt
dd if=/dev/zero of=swap bs=1024 count=524288
mkswap swap
chmod 0600 swap
swapon swap

To enable swap file when router booting, add this lines to /jffs/scripts/post-mount script

echo “” >>/jffs/scripts/post-mount
echo “swapon /opt/swap” >>/jffs/scripts/post-mount

To unmount swap add this lines to /jffs/scripts/services-stop script

echo “” >>/jffs/scripts/services-stop
echo “swapoff /opt/swap” >>/jffs/scripts/services-stop

EMAIL NOTIFICATIONS
If you have a slow internet connection and you want to be notified when a torrent has finished downloading, place the folowing script witch I called tmail.sh in /jffs/scripts but first don’t forget to fill: SMTP, FROM, TO, USER and PASS with your credentials.
WARNING, may become annoying if you are downloading lots of torrents…

#!/bin/sh

SMTP=”your-smtp-server:587″
FROM=”your-email-address”
TO=”your-email-address”
USER=”email-user-name”
PASS=”email-password”
FROMNAME=”Asus Router”
torrent_name=”$TR_TORRENT_NAME”echo “Subject: Download notification!” >/tmp/tmail.txt
echo “From: “$FROMNAME”<$FROM>” >>/tmp/tmail.txt
echo “Date: `date -R`” >>/tmp/tmail.txt
echo “” >>/tmp/tmail.txt
echo Transmissionbt has finished downloading “$TR_TORRENT_NAME” on `date +%d/%m/%Y` at `date +%T` >>/tmp/tmail.txt
echo “” >>/tmp/tmail.txt
echo “Your friendly router.” >>/tmp/tmail.txt
echo “” >>/tmp/tmail.txtcat /tmp/tmail.txt | /usr/sbin/sendmail -S”$SMTP” -f”$FROM” $TO -au”$USER” -ap”$PASS”

rm /tmp/tmail.txt

Stop transmission daemon, change this two lines in /opt/etc/transmission-daemon/settings.json and start transmission again

“script-torrent-done-enabled”: true,
“script-torrent-done-filename”: “/jffs/scripts/tmail.sh“,


TROUBLESHOOTING

If you have difficulties with installation process or transmissionbt usage, copy paste from terminal the next commands and post here followed by issue details:

uname -a
mount
df
free

transmission-2.84hqt