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.


My Second Book Published on Amazon

My Next book is finally complete! The book, titled What You REALLY Need to Know: Cisco Commands Made Easy, is now available on for download from Amazon in eReader format. You can check it out here.

Really Need to Know

Below is the introduction to the book:

I began writing this book as an introduction to the world of networking for new Network Engineers. After a few years on the job, I wanted to compile all of my notes, thoughts, and knowledge in a form that could help out others just starting their careers.

I entered my first job with a certain degree of confidence in my knowledge from taking multiple Cisco exams and perhaps an even greater amount of humility about what I didn’t know. This work is dedicated to the new guy on the job.

It’s intended as a hand reference to double check what’s been done and to provide helpful hints and advice on how to solve typical problems. It’s aiming to cover the topics on the exams that I found critical in my career, and especially covering the things the exams never prepared me for. It assumes some knowledge of basic networking concepts such as IPv4 addressing, subnetting, and the OSI model.

The goal is to present this information in an accessible and easy to understand manner, in contrast with other sources such as exam study material or Cisco documentation. It can be used as a reference for code examples, or read cover to cover to familiarize yourself with many topics.

Included are many practical labs and configuration examples. I encourage you to build them out, test them, and expand upon them to increase your knowledge.

The book is loosely organised into sections covering basic configuration, managing routers and switches, advanced configurations, switching, routing, WAN technologies, and security concepts. Feel free to jump to those you are most interested in or find most useful.

I hope you find the book useful. Thank you, and happy reading!

DIY Desk Building

Upon moving to a new apartment, I wanted to replace my cheap Ikea desk I had been using since college.

I really wanted a large surface area to place my dual monitors, speakers, keyboard and mouse and still have room for a laptop and any projects I was working on. I quickly found that it was very difficult to find a table to the dimensions I wanted, so I decided to build my own.

I decided to create my own table top and purchase legs for it. I found the perfect legs at Ikea, the FINNVARD. The trestles were designed for an architect style drafting table, were fully adjustable, and even had storage on the bottom.

I built the table top from two sheets of plywood from Home Depot.  The plywood was too thin for a single sheet to give the desired weight/feel, so I used cheap MDF for the bottom layer and a nicer sheet for the top layer. Home Depot even cut the sheets to size for me, around 6’x30″. The cuts were not exact, so I had to even out the discrepancies with a hand saw.

To attach the two boards together, I spread wood glue over the bottom layer, placed the top layer underneath, and used wood screws to bind them together. This firmly bonded the two sheets into one.

To cover up the sides and keep them visually pleasing I used thin 2″ molding . I only covered two sides and the front, to make things easier. I used brad nails and wood glue to attach the molding to the sides.

Finally, I painted the wood with a sealant. This added some shine and would help protect the wood.

My parents helped me get all of the supplies and assemble the table. You can see us all working on it together in the pictures below!

Raspberry Pi Webserver

I’ve been messing around with coding my own (very simple) website for the past few weeks. My goal was to write the HTML and CSS code myself, install my own web server, and host my own website at home.

I’ve been teaching myself basic HTML and CSS through several excellent free online guides, like this one at lifehacker. Through their lessons and a few others I was able to build my simple, acceptably attractive web site.

Next I needed a domain name so people could access the site without typing in my (always changing) IP address. For this I am using a free dynamic DNS service FreeDNS which has been working perfectly for me. My favorite thing about FreeDNS it that it doesn’t have any of the strings attached like dyndns or no-ip, it simply works. I am running a dydns client on my home router running DD-WRT that updates my DNS lisitng each time my IP address changes. I ended up using one of their free subdomains,

I recently purchased a Raspberry Pi and decided to set up an apache2 web server on it to host my website. Apache2 definitely isnt the fastest out there, but I wanted to get some experience with the ubiquitous web server, plus my site is fairly simple.

The pi is running the official Raspian image, based on Debian Linux. Once installed, the system performed like any other Linux server configured over SSH. Setting up Apache was simple, I installed the packages using apt-get, configured the apache2.conf file with some extra security parameters, and placed my website in the /var/www/ directory via SFTP. The web server is running as its own user, and it is jailed into its directory for extra security.

The last step was to allow access from the internet to my web server, which I accomplished using the port forwarding feature on my DD-WRT router.

For anyone interested in checking out my site, it will be (temporarily) accessible here. I’ll be monitoring the server logs for some hands on security testing!

If I have taken the site down, you check out a screenshot of the site below.


QNAP NAS as a Debian Linux Server

Several years ago I bought a QNAP TS-109 Network Attached Storage (NAS) device to use as a low power Linux server. I wanted a small server that would be always on, but would be quiet and would not use too much electricity.

After doing a lot of research on the options out there, I found an excellent guide for Installing Debian on the QNAP TS-109. The TS-109 II was one of the most powerful options out there at the time (in my price range) and it was able to run my Linux distribution of choice, Debian.

My NAS has been running faithfully for the past few years, but it was running some pretty old software so I thought it was time for an upgrade. I recently reinstalled my NAS with the newer Debian “Squeeze” release and thought I would document my progress here.

Installing OS

Installing Linux was pretty straightforward. Because I was already running an older Debian release, I simply downloaded and ran the files which copied the Debian installer to flash.

This was  all documented under the “download and flash the installer” section of the guide I linked to above. The install process is the same as the normal Debian CLI installer, only you connect to it via SSH.

After installing the OS I made sure to assign the NAS a static IP address, to make management easier.

Setup sshd

I chose the “ssh server” option during the Debian install, which installed an openssh-server. The only change I made here was in the /etc/ssh/sshd_config file, where I disabled root login.

I was originally planning on using SFTP for file transfer to/from the NAS, but on testing transfer speeds were horribly slow –  around 2 MB/s – I think this is due to the cryptography overhead of SSH, it is simply too much for the 500 MHz ARM processor in the TS-109.

To get around this problem, I installed an (unencrypted) FTP server.

Setup FTP

For my ftp server I chose proftpd, due to its simple configuration. Installing proftpd was simple (#apt-get install proftpd). To increase the security of the server I added a rule limiting login to the configuration file /etc/proftpd/proftpd.conf.

<Limit LOGIN>
DenyGroup !ftpuser

This prevents all users who are not members of the “ftpuser” group from logging in to the FTP server. I added my local user to the ftpuser group with this command.

#useradd ftpuser username

FTP is much faster than SFTP was. While my computer and the NAS both support Gigabit Ethernet, I only have a 100 Mb/s switch. The FTP server was able to transfer at around 11 MB/s, nearly the theoretical maximum of the interface.


Installing a BitTorrent client w/ web interface

I’ve been using rtorrent for a long time now. This command line BitTorrent client has worked well for me for a long time, but it is tedious to setup and use. I thought I would try something different this time.

I did my research on BitTorrent clients that can run on headless servers. I chose Transmission because I was comfortable with the client I had been using for a long time in Mac OS X and Linux. I found an excellent guide to installing the web interface client here.

Now it is up and running beautifully. It is much easier to use than rtorrent and I am very happy with my set up so far. The TS-109 does seem pretty limited by its processor, whenever performing an action the CPU is maxed at 100%. I have doubts that the NAS can transfer files at Gigbait Ethernet speeds.

You can see the transmission webclient and the cpu usage below:

Yet to come

Right now I am messing around with coding my own website. I signed up with a dynamic DNS service and I hope to be hosting my website locally. I hopefully will be configuring this in the coming weeks!