Seedboxes are useful when you work with large files over the internet. Although torrents are mis-associated with piracy, the decentralized P2P
architecture performs extremely well when large files have to be transferred. Transferring a 20GB
file over the Internet using either HTTP or FTP is a practical joke. Torrents are perhaps one of the greatest Internet innovations in the past few decades and have dramatically changed the way we perceive assets on the Internet.
We will be using opentracker
to announce torrents and rtorrent
to set-up the seed-box. opentracker
will take care of announcing the torrents added with rtorrent
and rtorrent
will be responsible for seeding them to connecting clients.
OpenTracker is a straight-forward torrent tracker. It is light-weight and runs entirely in RAM
without using up disk-space. Note that the job of a tracker is to just announce torrents, such that it is not necessary to allocate too many resources to OpenTracker. To set-up OpenTracker, we must first install libowfat0. On Debian, the package is provided by the repositiories and can be installed using aptitude install libowfat-dev libowfat0
. Otherwise, the official website suggest checking it out from CVS:
cvs -d :pserver:cvs@cvs.fefe.de:/cvs -z9 co libowfat cd libowfat make install cd ..
The next step is to clone OpenTracker from CVS and install it:
git clone git://erdgeist.org/opentracker cd opentracker make make install
The binary will be placed in /usr/bin/
.
Now that we have installed opentracker, the next step is to add a configuration file. This step is actually not necessary because OpenTracker can be configured from the command-line and takes very few parameters. Nevertheless, for the sake of consistency with other system-daemons, it is nice to have a configuration file around that can be easily changed.
We are going to create a new user and group under which OpenTracker will run. This can be easily achieved using:
groupadd opentracker useradd -g opentracker -G opentracker -d /srv/torrent opentracker mkdir /srv/opentracker chown -R opentracker: opentracker /srv/opentracker
this will allow us to use capabilities to restrict access, or even chroot
the setup if necessary.
Now, we create the /etc/opentracker.conf
file, with the following contents:
listen.udp.workers 4 listen.tcp_udp EXTERNAL_IP:63258 tracker.user opentracker
where:
EXTERNAL_IP
has to be changed to the external IP address that OpenTracker will bind to. This can also be set to 0.0.0.0
to listen on all interfaces.
By default, OpenTracker listens on port 6969
but in this case, we have set the port number to 63258
. In doing so, we can bypass some upstream ISP filtering. If we were to use the default setting, 6969
it becomes trivial for an ISP to block incoming connections in case your tracker becomes popular. This does not mean that 63258
cannot be blocked either, but ISPs usually perform some template-based blocking that may filter your tracker. A good port to choose is somewhere over the 61000
s because none of those are attributed to any particular service by IANA
. The tracker.user
setting represents the username under which OpenTracker will run.
Now the init script for OpenTracker can be fetched and added to /etc/init.d/opentracker
. After which, we activate OpenTracker so it will be started on reboot:
update-rc.d opentracker defaults
rtorrent
is a light-weight console-based torrent client. It is comparable to ctorrent
, which is smaller, but rTorrent also provides an interface that can be controlled using key-combos. To install rTorrent in Debian, issue:
aptitude install rtorrent
Additionally, create an user for rTorrent:
groupadd rtorrent useradd -g rtorrent -G rtorrent -d /srv/rtorrent rtorrent mkdir /srv/rtorrent chown -R rtorrent:rtorrent /srv/rtorrent
The next step is to create a directory structure that will hold downloads and an additional directory where we can just drop torrent files so that rTorrent picks them up automatically.
mkdir -p /srv/rtorrent/{downloads,torrents} chown -R rtorrent:rtorrent /srv/rtorrent/{downloads,torrents}
Now we add a configuration file for rtorrent
by editing /srv/torrent/.rtorrent.rc
:
directory = /srv/rtorrent/downloads/ schedule = watch_directory,5,5,load_start=/srv/rtorrent/torrents/*.torrent schedule = untied_directory,5,5,stop_untied= ip = EXTERNAL_IP bind = EXTERNAL_IP port_range = 64050-64100 port_random = yes check_hash = true use_udp_trackers = yes encryption = require,require_RC4,allow_incoming,try_outgoing,enable_retry dht = auto dht_port = 6889 peer_exchange = yes
Some of these settings are important, for example:
EXTERNAL_IP
has to be substituted for the external IP.port_range
has to be changed while making sure that it does not overlap with the listen.tcp_udp
of OpenTracker from the previous section.encryption
setting is particularly important and the way this is set-up in the configuration file above, it forces encryption on all connections. This is important because most of the problems with slow download speeds are due to the fact that torrent clients are set to not use encryption at all which makes it easier for upstream ISPs to block transfers. This should be left unchanged and configured exactly as shown in the example above.
Now, the way that rTorrent is set-up is that on start-up, it will read all the torrent
files placed in /srv/rtorrent/torrents
and will automatically queue them up and start downloading to /srv/rtorrent/downloads
.
The final step is to install tmux
that will allow us to run rTorrent in a multiplexed console so that we can manipulate torrents by accessing rTorrent's interface:
aptitude install tmux
And then download the rtorrent init script and place it in /etc/init.d/rtorrent
. After making the appropriate changes, set it to run on boot by issuing:
update-rc.d rtorrent defaults
Now that the set-up is complete, we can start OpenTracker and rTorrent with:
service opentracker restart service rtorrent restart
and then su
to torrent
in order to check the torrent status by attaching to the tmux
rtorrent
session created by the init
script:
su torrent tmux attach-session -t rtorrent
you will be placed in a multiplexed terminal. After toying with rtorrent
, you can background the session by hitting the Ctrl+B D key-combo.
Any torrent file placed in /srv/rtorrent/torrents
will be automatically added to the queue by rTorrent. A good idea is to use samba share permissions to share both the /srv/rtorrent/downloads
and the /srv/rtorrent/torrents
folder.