Running BitTorrent on an OpenWRT Router

Over the weekend I decided to set up my OpenWRT router with a BitTorrent client. Thanks to opkg, its really easy to install the Transmission BitTorrent client on your router.


Before you can get transmission running you’ll need to set up a USB drive for storage. Most routers have very little flash storage so you’ll have to add USB storage to store your downloaded content.

Setting up USB support is fairly simple, it just requires a few packages to be installed. Let’s install all the packages we’ll need first.

opkg update
opkg install transmission-web e2fsprogs cfdisk kmod-fs-ext4 kmod-usb-storage block-mount

These utilities enable usb support (kmod-usb-storage), allow mounting external storage (block-mount), partition your usb drive (cfdisk), and create/use the ext4 file system  (e2fsprogs, kmod-fs-ext4).

First plug in your USB drive and create one big Linux partition. I used cfdisk for this; just delete the existing partition (/dev/sda1 on my router) and create a new primary partition. By default it selects the right partition type (Linux).


Next you need to create a file system on the USB drive. mkfs.ext4 will create an ext4 file system on the drive. I mounted the new file system under /mnt.

mkfs.ext4 -F /dev/sda1
mount /dev/sda1 /mnt

Next lets make sure the drive is mounted automatically on boot. We’ll need to make a /etc/config/fstab file for this, and then enable the fstab process on boot. I also made the directories Transmission will use in /mnt.

cat <<EOT >> /etc/config/fstab
config 'mount'
 option 'device' '/dev/sda1'
 option 'options' 'rw,sync'
 option 'enabled_fsck' '0'
 option 'enabled' '1'
 option 'target' '/mnt'

/etc/init.d/fstab enable

mkdir /mnt/downloads
mkdir /mnt/watch

Once we’ve got the drive set up we can start configuring Transmission. We’ll need to create a Transmission config file which downloads torrents to our USB drive and we’ll need to configure Transmission to start automatically on boot.

#Load Transmission Config File

rm -rf /etc/config/transmission

cat <<EOT >> /etc/config/transmission
config transmission
 option enabled 1
 option config_dir '/mnt/transmission'
 #option user 'nobody'
 option alt_speed_down 0
 option alt_speed_enabled false
 option alt_speed_time_begin 540
 option alt_speed_time_day 127
 option alt_speed_time_enabled false
 option alt_speed_time_end 1020
 option alt_speed_up 0
 option bind_address_ipv4 ''
 option bind_address_ipv6 '::'
 option blocklist_enabled false
 option blocklist_url ''
 option cache_size_mb 2
 option dht_enabled true
 option download_dir '/mnt/downloads/'
 option download_queue_enabled true
 option download_queue_size 2
 option encryption 1
 option idle_seeding_limit 0
 option idle_seeding_limit_enabled false
 option incomplete_dir '/mnt/incomplete'
 option incomplete_dir_enabled false
 option lazy_bitfield_enabled true
 option lpd_enabled false
 option message_level 1
 option peer_congestion_algorithm ''
 option peer_limit_global 240
 option peer_limit_per_torrent 60
 option peer_port 33333
 option peer_port_random_high 65535
 option peer_port_random_low 50000
 option peer_port_random_on_start false
 option peer_socket_tos 'default'
 option pex_enabled true
 option port_forwarding_enabled true
 option preallocation 1
 option prefetch_enabled true
 option queue_stalled_enabled true
 option queue_stalled_minutes 30
 option ratio_limit 2.0000
 option ratio_limit_enabled false
 option rename_partial_files true
 option rpc_authentication_required false
 option rpc_bind_address ''
 option rpc_enabled true
 option rpc_password ''
 option rpc_port 9091
 option rpc_url '/transmission/'
 option rpc_username ''
 option rpc_whitelist ',192.168.1.*'
 option rpc_whitelist_enabled true
 option scrape_paused_torrents_enabled true
 option script_torrent_done_enabled false
 option script_torrent_done_filename ''
 option seed_queue_enabled false
 option seed_queue_size 10
 option speed_limit_down 0
 option speed_limit_down_enabled false
 option speed_limit_up 500
 option speed_limit_up_enabled false
 option start_added_torrents true
 option trash_original_torrent_files false
 option umask 18
 option upload_slots_per_torrent 20
 option utp_enabled true
 option scrape_paused_torrents true
 option watch_dir_enabled true
 option watch_dir '/mnt/watch'

#Automatically load transmission on boot

/etc/init.d/transmission enable
/etc/init.d/transmission start

After you’ve set up Transmission you can access it at and start downloading!


Most routers have very limited CPU and Memory resources. I saw not-so-stellar performance when downloading using OpenWRT, but seeding performance was pretty good – I was able to saturate my upload link.

I think this would be a great setup if you’d like to seed files for a long time, or if you’d like to download overnight while your main computer is off to save some electricity. Plus its really cool running BitTorrent directly on your router!

I created a script to set up an OpenWRT router with Transmission, hosted on my github account. It does everything aside from partition the USB drive for you, which you can do with cfdisk. Feel free to check out the script here.