It’s pretty practical to download torrents directly on a router running OpenwWrt, instead of using another device like a smartphone, laptop or a Raspberry Pi.
Well, not every cheap router can do this, but many can do. Just make sure the router have a USB port and it supports OpenWrt.
In a previous post, I wrote about the same thing, but in a different way, OpenWrt torrent downloader box with rtorrent and LuCI based web interface.
If you’re a Linux user, probably you are more familiar with the Transmission torrent client. It’s also possible to run Transmission on OpenWrt routers and monitor it through the web interface.
1. Install transmission and other necessary packages
Though You can install packages through LuCI interface, but it’s easier to install them through command line.
After logging in to the router via SSH, update the opkg package repository and install transmission.
ssh [email protected] # On Linux, Mac
Or use Putty if you’re on Windows.
Update the repository and install the transmission-web package.
opkg install transmission-web
The transmission-web package and it’s dependencies will consume around 1.2 MB of free space, make sure you have enough free space left on the router, or setup extroot .
2. Configure Transmission on OpenWrt
Now edit the default transmission configuration to make it usable, the OpenWrt specific configuration file is /etc/config/transmission .
Here an example configuration bellow,
vi /etc/config/transmission # On OpenWrt
config transmission option enabled 1 option config_dir '/mnt/sda1/transmission' option download_dir '/mnt/sda1/Downloads' option incomplete_dir '/mnt/sda1/incomplete' #option user 'nobody' option alt_speed_down 50 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 50 option bind_address_ipv4 '0.0.0.0' option bind_address_ipv6 '::' option blocklist_enabled false option blocklist_url '' option cache_size_mb 2 option dht_enabled true option download_queue_enabled true option download_queue_size 4 option encryption 1 option idle_seeding_limit 30 option idle_seeding_limit_enabled false 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 51413 option peer_port_random_high 65535 option peer_port_random_low 49152 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 true option rpc_bind_address '0.0.0.0' option rpc_enabled true option rpc_password '1234' option rpc_port 9091 option rpc_url '/transmission/' option rpc_username 'MyUserName' option rpc_whitelist '127.0.0.1,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 100 option speed_limit_down_enabled false option speed_limit_up 20 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 14 option utp_enabled true option scrape_paused_torrents true option watch_dir_enabled false option watch_dir ''
- A partition of USB drive(/dev/sda1) is mounted at /mnt/sda1 , you must change the the download_dir and incomplete_dir options to avoid running out of space. You can use any folder location, just make sure it have enough free space to download the torrrents.
- Edit the
/etc/config/fstabfile to automatically mount the /dev/sda1 partion to /mnt/sda1 after each boot.
- You may also want to password protect the Web/RPC controll interface, change the rpc_authentication_required option to true .
- Also don’t forget to change the RPC interface username and password, chenge these two options, rpc_username and rpc_password .
After saving the configuration, start the transmission daemon.
Also enable automatic startup of the transmission deamon.
3. Setup swap space on the router
Transmission performs better when a little swap space is available.
In fact on routers with 32 MB of RAM, running the transmission deamon will result in utterly laggy performance, but adding as little as 4 MB of swap space will improve the scenario a lot.
You can use a dedicated swap partition on the USB drive or use a swap file, there is no significant performance difference between them.
I’m going with the swap file approach here, assuming you are using extroot and have enough free space on the extroot partition.
- Create a 16 MB blank file,
dd if=/dev/zero of=swap-file bs=1M count=16
- Format is as swap,
- Turn on the swap space,
- To mount the swap space automatically at every boot, add this line bellow to the
/etc/rc.localfile before the
exit 0line .
Add few kernel parameters listed bellow to the
/etc/sysctl.conf file and run
sysctl -p, this will result in more effective use of the swap space.
vm.vfs_cache_pressure=200 vm.min_free_kbytes=4096 vm.overcommit_memory=2 vm.overcommit_ratio=60 vm.swappiness=95
Adding swap space may not be necessary for routers with 128 MB or more RAM.
4. Testing the OpenWrt torrent downloader
Open up your favorite browser and type 192.168.1.1:9091 in the address bar, it should prompt you to enter the preconfigurd RPC username and password.
The Transmission web interface is much like it’s GUI counterparts, if everything is configured properly, you can add torrent files to download or add magnet liks.
You can also controll the openwrt torrent downloader through Transmission GUI clients, I’m using the Qtransmission client to controll it.
In Qtransmission, go through the Edit > Change Session > Connect to Remote Session and enter proper Host, Port, Username and Password to connet a remote session.
The same thing could be done with the gtk+ version of the Transmission for Linux, transmission-gtk .
Now, it’s ready, your 24×7 running and low power consuming openwrt torrent downloader, it’s cheper to make too !
My previous failed attemp to run transmission reliably was only due to 32 MB of RAM, now it works fine.
If you have any suggestion or question, please feel free to leave comment, sharing this tutorial on social networks is also highly appreciated.