Difference between revisions of "Deluge"

From ArchWiki
Jump to: navigation, search
(daemon)
(change category to Category:BitTorrent)
 
(134 intermediate revisions by 42 users not shown)
Line 1: Line 1:
{{i18n|Deluge}}
+
[[Category:BitTorrent]]
[[Category:Internet Applications (English)]]
+
[[de:Deluge]]
 +
[[es:Deluge]]
 +
[[ja:Deluge]]
 +
[[ko:Deluge]]
 +
{{Related articles start}}
 +
{{Related|rTorrent}}
 +
{{Related|systemd}}
 +
{{Related|systemd/User}}
 +
{{Related|iptables}}
 +
{{Related|OpenSSL}}
 +
{{Related articles end}}
  
[[de:Deluge Installation]]
+
[http://deluge-torrent.org/ Deluge] is a full-featured BitTorrent application written in Python 2. It has a variety of features, including but not limited to: a client/server model, DHT support, magnet links, a plugin system, UPnP support, full-stream encryption, proxy support, and three different client applications. When the server daemon is running, users can connect to it via a console client, a GTK+-based GUI, or a Web-based UI. A full list of features can be viewed [http://dev.deluge-torrent.org/wiki/About here].
  
This article will show you how to set up Deluge also for daemon-based torrenting.
+
== Installation ==
  
==Base Install==
+
Install {{Pkg|deluge}}. GTK+ client also needs {{Pkg|pygtk}} package to run.
Deluge is available in the official repositories:
 
# pacman -S deluge
 
  
==Graphical Clients==
+
== Daemon ==
===Web ui===
+
Deluge works with a client/server model. The server is referred to as the daemon and runs in the background waiting for a client (console, gtk, or web-based) to connect. The client can disconnect but the daemon continues to run transferring the torrent files in the queue.
The Web-ui runs on the server and the clients only need a Web-Browser.
 
You need to install '''python2-mako''' on the server:
 
# pacman -S python2-mako
 
  
===Gtk ui===
+
Upon installation, pacman will create a non-privileged '''deluge''' user.  This user is meant to run the provided daemon, {{ic|/usr/bin/deluged}}. Users are able to start the daemon several ways:
The Gtk ui needs to have '''pygtk''' and '''librsvg''' installed on the clients:
+
# Systemd system service (runs as the deluge user).
# pacman -S pygtk librsvg
+
# Systemd user service (runs as another user).
 +
# Running it directly (runs as another user).
  
==Configuration==
+
{{Tip|For the highest level of security, running {{ic|deluged}} via the systemd system service ({{ic|deluged.service}}) is recommended since the deluge user has no shell access (limited account) or other group affiliation on the host system.  In addition to the security benefits of running as the non-privileged deluge user, the system service can also run at boot without the need to start Xorg or a client.}}
If You want to run Deluge as user just run:
 
# deluge -u [gtk|web|console]
 
  
===daemon===
+
=== System service ===
The default user for deluged, the Deluge daemon, is "deluge". You can change this in {{filename|/etc/conf.d/deluged}}. Of course, the user needs to exist. In the case of the default "deluge" user, no manual user creation is necessary as the package script has done that for you.
 
  
The rest of this guide will assume you use the default "deluge" user. This user's default home dir and therefore its configuration location is in ''/srv/deluge''. This should be fine under most circumstances. Note that this is NOT the default download location, it only holds its configuration and ssl certificates. You will be able to change all other options later on once you get a client working.
+
[[Start]] the service and optionally [[enable]] it if running at boot is desired.
  
Next, start the daemon to generate its default configuration in its homedir:
+
=== User service ===
# rc.d start deluged
 
  
And add it to Your {{filename|/etc/rc.conf}}, so it gets convieniently autostarted:
+
{{Warning|If multiple users are running a daemon, the default port (58846) will need to be changed for each user.}}
DAEMONS=( ... network '''deluged''' ... )
+
A user service will allow {{ic|deluged}} to run when {{ic|systemd --user}} is started. This is accomplished by creating a user service file:
 +
{{hc|/etc/systemd/user/deluged.service|<nowiki>
 +
[Unit]
 +
Description=Deluge Daemon
 +
After=network.target
  
===Gtk ui===
+
[Service]
Stop the Deluge daemon:
+
ExecStart=/usr/bin/deluged -d -P %h/.config/deluge/deluge.pid
# /etc/rc.d/deluged stop
 
  
If You want to connect remotely via the Gtk ui, there should be something like this in {{filename|/srv/deluge/.config/deluge/core.conf}}:
+
[Install]
"allow_remote": true,
+
WantedBy=default.target
 +
</nowiki>}}
 +
The deluge user service can now be [[start]]ed and enabled by the user.
  
Now add yourself to the authentification file:
+
The {{ic|deluged}} user service can also be placed in {{ic|$HOME/.config/systemd/user/}}. See [[systemd/User]] for more information on user services.
# echo "yourusername:yourpassword:10" >> /srv/deluge/.config/deluge/auth
 
  
'''10''', the authentification level is not used at this time. Read [http://dev.deluge-torrent.org/wiki/UserGuide/Authentication more] about that.
+
== Configuration ==
  
Start the Deluge daemon again.
+
Deluge can be configured through any of the clients as well as by simply editing the JSON-formatted configuration files located in {{ic|$HOME/.config/deluge/}}. '''$HOME''' refers to the home directory of the user that {{ic|deluged}} is running as. This means that if the daemon is running as the '''deluge''' user, the default home directory is {{ic|/srv/deluge/}}.
  
Now start the Gtk ui. If You prefer, You can edit the preferences in {{filename|~/.config/deluge/gtkui.conf}}, but there's also a nice configuration tool in the ui.
+
=== Shared directories for downloads/uploads ===
 +
When using the systemd deluged.service, the shared directory/directories need to be shared so that other users on the system are able to access the data. The general strategy is to:
  
Look for '''classic mode''' and disable it. Have You seen an icon just pop up? Hit it! If not go to Edit -> Connection Manager and add Your daemon.
+
# Change the owner and group of the shared directory to deluge:deluge.
 +
# Set the [[File permissions and attributes]] on the shared directory to at least 770.
 +
# Add your user (or the user/users needing to access the files) to the deluge group.
  
===Web ui===
+
Example using {{ic|/mnt/torrent_data}}:
First, start the web ui daemon:
+
# chown -R deluge:deluge /mnt/torrent_data
  # /etc/rc.d/deluge-web start
+
  # chmod 770 /mnt/torrent_data
 +
# usermod -a -G deluge YOURUSER
  
and login in on ''http://deluge-machine:8112''. Where 'deluge-machine' is name of your deluge server or its private or public IP address. When asked for a password, enter "deluge" as it's the default password.
+
{{Note|When usermod is used to change group affiliation, a logout/login is required before changes take effect.}}
  
The preferences in the web ui should be rather self explanatory and the first obvious thing to do is to change your password.
+
=== Firewall ===
  
As usual, you should add the daemons to your {{filename|/etc/rc.conf}}:
+
Deluge requires at least one port open for TCP and UDP to allow incoming connections for seeding. If deluge complaining that it cannot open a port for incoming connections, users must open port(s) to be used. In this example, ports 56881 through 56889 are opened for TCP and UDP:
  DAEMONS=( ... network deluged '''deluge-web''' ... )
+
# iptables -A INPUT -p tcp --dport 56881:56889 -j ACCEPT
 +
  # iptables -A INPUT -p udp --dport 56881:56889 -j ACCEPT
 +
User who are behind a NAT router/firewall must setup the corresponding ports to be forwarded. UPnP may also be used, but that will not work with the local firewall on the system because it requires predefined ports.
 +
{{Note|One can limit this to a single port, just be sure to enable both TCP and UDP.}}
  
Just make sure your network connection is up at the time you start either of those Deluge daemons.
+
On many default configurations, when using iptables with connection tracking (conntrack) set to drop "INVALID" packets, sometimes a great deal of legitimate torrent traffic (especially DHT traffic) is dropped as "invalid." This is typically caused by either conntrack's memory restrictions, or from long periods between packets among peers (see [http://libtorrent.rakshasa.no/wiki/RTorrentUsingDHT] towards the bottom and [http://www.linuxquestions.org/questions/showthread.php?p=5145026]). Symptoms of this problem include torrents not seeding, especially when the torrent client has been active for more than a day or two continuously, and consistently low overhead traffic (in one experience, less than 3KiB/s in either in or out) with DHT enabled, even when deluge/libtorrent has been continuously running for more than forty-eight hours and many torrents are active. For this reason, it may be necessary to disable connection tracking of all torrent traffic for optimal performance, even with the listening ports set to ACCEPT (as the causes for dropping INVALID packets, for instance conntrack's memory problems, may supercede any rules to accept traffic to/from those ports).
  
{{Note|In the current version of Deluge (1.3.1) the WebUI will not work in Google Chrome unless system time is configured properly. The WebUI will load, but upon entry of the password prompt, it will return as if nothing had been entered. This is Chrome thinking the session has expired. The quick and easy way of solving this issue is to install the [[Network Time Protocol daemon|ntp]] package and add ''ntpd'' to your DAEMONS in {{filename|/etc/rc.conf}}.}}
+
To fully turn off connection tracking for torrents, specify ports for both Incoming and Outgoing traffic in Deluge, for instance, 56881-56889 for incoming connections and 56890-57200 for outgoing connections.
 +
{{Note|Limiting incoming connections is not recommended with libtorrent as this will limit the ability to keep multiple connections to the same client, even for different torrents.}}
  
==Automatically Connect To Daemon==
+
Then issue the following commands (after substituting the relevant port ranges):
If you want to avoid clicking "connect" everytime you start the deluge web-ui, edit the web.conf file in your configuration directory (usually /srv/deluge/.config/deluge).  
+
  # iptables -t raw -I PREROUTING -p udp --dport 56881:57200 -j NOTRACK
It should have a line like this towards the bottom:
+
# iptables -t raw -I OUTPUT -p udp --sport 56881:57200 -j NOTRACK
  '''
+
  # iptables -t raw -I PREROUTING -p tcp --dport 56881:57200 -j NOTRACK
  "default_daemon": ""
+
  # iptables -t raw -I OUTPUT -p tcp --sport 56881:57200 -j NOTRACK
 +
# iptables -I INPUT -p icmp --icmp-type 3 -j ACCEPT
 +
# iptables -I INPUT -p icmp --icmp-type 4 -j ACCEPT
 +
# iptables -I INPUT -p icmp --icmp-type 11 -j ACCEPT
 +
# iptables -I INPUT -p icmp --icmp-type 12 -j ACCEPT
 +
The ICMP allowances are desirable because once connection tracking is disabled on those ports, those important ICMP messages (types 3 (Destination Unreachable), 4 (Source Quench), 11 (Time Exceeded) and 12 (Parameter Problem)) would otherwise be declared INVALID themselves (as netfilter would not know of any connections that they are associated with), and they would potentially be blocked.
 +
{{Warning|A port range of 1024:65535 would break every DNS query.}}
  
Change it to:
+
=== Plugins ===
'''
+
{{Note|Plugins should be compiled with Python2.7: e.g. {{ic|$ python2.7 ''setup.py build''}}.}}
"default_daemon": "127.0.0.1:58846"
 
  
This assumes that your deluge port is the default 58846.
+
A complete list of plugins can be found on the [http://dev.deluge-torrent.org/wiki/Plugins Deluge Wiki]
  
 +
[https://github.com/ratanakvlun/deluge-ltconfig ltConfig] is a useful plugin that allows direct modification to libtorrent settings and has preset support.
  
====SSL====
+
It offers additional settings like {{ic|announce_ip}} (IP to announce to trackers), {{ic|half_open_limit}} (Remove maximum half-open connections limit) and more possible privacy and (seed) speedboost features.
In case you want SSL for the web ui, you need to generate a new cert/key set. To do this, first stop the web ui:
 
  
# /etc/rc.d/deluge-web stop
+
== Clients ==
  
then go to ''/srv/deluge/.config/deluge/ssl/'' and issue:
+
=== Console ===
  
  # openssl req -new -x509 -nodes -out deluge.cert.pem -keyout deluge.key.pem
+
The console client can be run with:
 +
  $ deluge-console
 +
Enter the {{ic|help}} command for a list of available commands.
  
Next you need to edit {{filename|/srv/deluge/.config/deluge/web.conf}} and change the '''pkey''' and '''cert''' configuration directives to use your new self-signed certificates and also enable SSL:
+
=== GTK+ ===
...
 
"pkey": "ssl/deluge.key.pem",
 
...
 
"cert": "ssl/deluge.cert.pem",
 
...
 
"https": true,
 
  
Afterwards just start the web ui again and you should be good to go:
+
{{Note|It is necessary to disable Classic Mode in ''Edit -> Preferences -> Interface'' for daemon (server) setups.}}
  
  # /etc/rc.d/deluge-web start
+
The GTK+ client can be run with:
 +
  $ deluge-gtk
 +
or:
 +
$ deluge
  
==Resources==
+
The GTK+ client has a number of useful plugins:
[http://deluge-torrent.org/ Deluge Homepage]
+
* AutoAdd - Monitors directories for .torrent files
 +
* Blocklist - Downloads and imports an IP blocklist
 +
* Execute - Event-based command execution
 +
* Extractor - Extracts archived files upon completion '''''(beware of random high disk I/O usage)'''''
 +
* Label - Allows labels to be assigned to torrents, as well as state, tracker, and keyword filters
 +
* Notifications - Provides notifications (email, pop-up, blink, sound) for events as well as other plugins
 +
* Scheduler - Limits active torrents and their speed on a per-hour, per-day basis
 +
* WebUi - Allows the Web UI to be started via the GTK+ client
 +
 
 +
=== Web ===
 +
A web-client is also provided should users not want GTK or shell-based access to the daemon. 
 +
 
 +
The {{Pkg|python2-mako}} dependency is needed for the web client to work. When the web client is initially started, it will create {{ic|$HOME/.config/deluge/web.conf}}. The password in this file is hashed with SHA1 and salted. The default password is "deluge".
 +
 
 +
Just as with deluge daemon mentioned above, the web client as can be started several different ways:
 +
# Systemd system service (runs as the deluge user).
 +
# Systemd user service (runs as another user).
 +
# Running it directly (runs as another user).
 +
 
 +
{{Tip|For the highest level of security, running {{ic|deluge-web}} via the systemd system service ({{ic|deluge-web.service}}) is recommended since the deluge user has no shell access (limited account) or other group affiliation on the host system.  In addition to the security benefits of running as the non-privileged deluge user, the system service can also run at boot without the need to start Xorg or a client.}}
 +
 
 +
Several things to note:
 +
* The web client offers many of the same features of the GTK+ UI, including the plugin system.
 +
* It is recommended to use HTTPS for the Web client to protect against a man-in-the-middle attack.
 +
* Users may  be greeted by a warning from the browser that the SSL certificate is untrusted. Add an exception to this in the browser to continue on. See the [[OpenSSL]] page for information on creating your own certificate.
 +
* If multiple users are running a daemon, the default port (8112) will need to be changed for each user.
 +
 
 +
Once running, users may connect to the web client by browsing to http://hostname:8112 or if using encryption: https://hostname:8112
 +
 
 +
==== System service ====
 +
Deluge ships with {{ic|deluge-web.service}}, a systemd system unit, which is used to [[start]] the Deluge Web UI. The Deluge Web UI uses a Connection Manager, allowing managing of multiple Deluge clients running under the same host or on an entirely different one. Remember to [[start]] and optionally [[enable]] the {{ic|deluged}} service to allow the Web UI connect to the host Deluge client.
 +
 
 +
==== User service ====
 +
A user service will allow {{ic|deluge-web}} to run when {{ic|systemd --user}} is started. This is accomplished by creating a user service file:
 +
{{hc|/etc/systemd/user/deluge-web.service|<nowiki>
 +
[Unit]
 +
Description=Deluge Web UI
 +
After=deluged.service
 +
 
 +
[Service]
 +
ExecStart=/usr/bin/deluge-web --ssl
 +
 
 +
[Install]
 +
WantedBy=default.target
 +
</nowiki>}}
 +
The deluge user service can now be [[start]]ed and enabled by the user.
 +
 
 +
The {{ic|deluge-web}} user service can also be placed in {{ic|$HOME/.config/systemd/user/}}. See [[systemd/User]] for more information on user services.
 +
 
 +
== Headless setup ==
 +
 
 +
Deluge is quite useful on a headless system, often referred to as a seed box, because of its client/server model. To set up deluge on a headless system, set up the daemon as shown above.
 +
 
 +
=== Create a user ===
 +
 
 +
To allow interaction with the server remotely, create a user in {{ic|$HOME/.config/deluge/auth}}. For example:
 +
$ echo "delugeuser:p422WoRd:10" >> $HOME/.config/deluge/auth
 +
{{Note|
 +
* The user/password created does not have to match any system users, and to maintain good security practices it should '''not'''!
 +
* The user/password in this file are not hashed or salted like in the web client config.
 +
* The user/password must match the user/password found in /srv/deluge/.config/deluge/auth otherwise the authentication fails.
 +
}}
 +
 
 +
The number '''10''' corresponds to a level of '''Admin'''.  Refer to the following table for additional values:
 +
 
 +
{| class="wikitable" align="center"
 +
|-
 +
! Level Name !! Level Value
 +
|-
 +
| None || 0
 +
|-
 +
|Read Only || 1
 +
|-
 +
| Normal || 5
 +
|-
 +
| Admin || 10
 +
|}
 +
 
 +
{{Note|In Deluge 1.35, these values have no effect, but multiuser options are under development.}}
 +
 
 +
=== Allow remote ===
 +
 
 +
The default settings disallow remote connections. Change the "allow_remote" setting in {{ic|$HOME/.config/deluge/core.conf}}:
 +
"allow_remote": true
 +
{{Note|
 +
1. {{ic|$HOME/.config/deluge/core.conf}} is automatically created at the first configuration change, if it does not exist you can set the value via {{ic|deluge-console}}:
 +
config --set allow_remote true
 +
2. Changes made while the service is running won't be read into the daemon, therefore, stop the service before making changes to this file.
 +
}}
 +
 
 +
=== Firewall ===
 +
 
 +
Open the port for remote access. The following example uses the default daemon port (58846):
 +
# iptables -A INPUT -p tcp --dport 58846 -j ACCEPT
 +
See [[iptables]] for more information on firewall rules.
 +
 
 +
Users behind a NAT router/firewall must forward the port to access the daemon from outside the network if this behavior is desired.
 +
 
 +
=== Connect ===
 +
 
 +
In the console client:
 +
connect <host>[:<port>] <user> <password>
 +
 
 +
In the GTK+ client, ''Edit > Connection Manager > Add''.
 +
 
 +
In the Web client, ''Connection Manager > Add''.
 +
 
 +
==== SSH Tunnel ====
 +
An SSH tunnel can be created to use an encrypted connection on any client. This requires an extra loopback address to be added, but this can be automated at boot. Without this step, the connection would be considered local. The actual command to establish an SSH tunnel cannot be automated as it requires user input. There are a few possible ways to go about doing that.
 +
{{hc|/etc/systemd/system/extra_lo_addr.service|<nowiki>
 +
[Unit]
 +
Description=extra loopback address
 +
Wants=network.target
 +
 
 +
[Service]
 +
Type=oneshot
 +
RemainAfterExit=yes
 +
ExecStart=/sbin/ip addr add 127.0.0.2/8 dev lo
 +
ExecStop=/sbin/ip addr del 127.0.0.2/8 dev lo
 +
 
 +
[Install]
 +
WantedBy=multi-user.target
 +
</nowiki>}}
 +
 
 +
$ ssh -fNL 127.0.0.2:58846:localhost:58846 <ssh host>
 +
The port '''58846''' should be replaced with the port the deluge server is running on and '''<ssh host>''' should be replaced with the server hosting both deluge and the SSH server.
 +
 
 +
== Troubleshooting ==
 +
 
 +
=== No module named service_identity ===
 +
 
 +
Upon running {{ic|deluged}} or {{ic|deluge-console}}, you may recieve a message like the following:
 +
 
 +
:0: UserWarning: You do not have a working installation of the service_identity module: 'No module named service_identity'. 
 +
Please install it from <https://pypi.python.org/pypi/service_identity> and make sure all of its dependencies are satisfied. 
 +
Without the service_identity module and a recent enough pyOpenSSL to support it, Twisted can perform only rudimentary TLS
 +
client hostname verification.  Many valid certificate/hostname mappings may be rejected.
 +
 
 +
You may be missing {{Pkg|python2-service-identity}}, which is an optional dependency to {{Pkg|python2-twisted}}. See {{Bug|43806}}.
 +
 
 +
=== Web ui .torrent upload does not work ===
 +
 
 +
If you are running the web ui behind a reverse proxy, you need to allow embedding for .torrent upload to work (X-Frame-Options ALLOW)
 +
 
 +
== See Also ==
 +
* [http://deluge-torrent.org/ Deluge homepage]
 +
* [http://dev.deluge-torrent.org/wiki Deluge wiki]

Latest revision as of 19:50, 22 October 2018

Deluge is a full-featured BitTorrent application written in Python 2. It has a variety of features, including but not limited to: a client/server model, DHT support, magnet links, a plugin system, UPnP support, full-stream encryption, proxy support, and three different client applications. When the server daemon is running, users can connect to it via a console client, a GTK+-based GUI, or a Web-based UI. A full list of features can be viewed here.

Installation

Install deluge. GTK+ client also needs pygtk package to run.

Daemon

Deluge works with a client/server model. The server is referred to as the daemon and runs in the background waiting for a client (console, gtk, or web-based) to connect. The client can disconnect but the daemon continues to run transferring the torrent files in the queue.

Upon installation, pacman will create a non-privileged deluge user. This user is meant to run the provided daemon, /usr/bin/deluged. Users are able to start the daemon several ways:

  1. Systemd system service (runs as the deluge user).
  2. Systemd user service (runs as another user).
  3. Running it directly (runs as another user).
Tip: For the highest level of security, running deluged via the systemd system service (deluged.service) is recommended since the deluge user has no shell access (limited account) or other group affiliation on the host system. In addition to the security benefits of running as the non-privileged deluge user, the system service can also run at boot without the need to start Xorg or a client.

System service

Start the service and optionally enable it if running at boot is desired.

User service

Warning: If multiple users are running a daemon, the default port (58846) will need to be changed for each user.

A user service will allow deluged to run when systemd --user is started. This is accomplished by creating a user service file:

/etc/systemd/user/deluged.service
[Unit]
Description=Deluge Daemon
After=network.target

[Service]
ExecStart=/usr/bin/deluged -d -P %h/.config/deluge/deluge.pid

[Install]
WantedBy=default.target
 

The deluge user service can now be started and enabled by the user.

The deluged user service can also be placed in $HOME/.config/systemd/user/. See systemd/User for more information on user services.

Configuration

Deluge can be configured through any of the clients as well as by simply editing the JSON-formatted configuration files located in $HOME/.config/deluge/. $HOME refers to the home directory of the user that deluged is running as. This means that if the daemon is running as the deluge user, the default home directory is /srv/deluge/.

Shared directories for downloads/uploads

When using the systemd deluged.service, the shared directory/directories need to be shared so that other users on the system are able to access the data. The general strategy is to:

  1. Change the owner and group of the shared directory to deluge:deluge.
  2. Set the File permissions and attributes on the shared directory to at least 770.
  3. Add your user (or the user/users needing to access the files) to the deluge group.

Example using /mnt/torrent_data:

# chown -R deluge:deluge /mnt/torrent_data
# chmod 770 /mnt/torrent_data
# usermod -a -G deluge YOURUSER
Note: When usermod is used to change group affiliation, a logout/login is required before changes take effect.

Firewall

Deluge requires at least one port open for TCP and UDP to allow incoming connections for seeding. If deluge complaining that it cannot open a port for incoming connections, users must open port(s) to be used. In this example, ports 56881 through 56889 are opened for TCP and UDP:

# iptables -A INPUT -p tcp --dport 56881:56889 -j ACCEPT
# iptables -A INPUT -p udp --dport 56881:56889 -j ACCEPT

User who are behind a NAT router/firewall must setup the corresponding ports to be forwarded. UPnP may also be used, but that will not work with the local firewall on the system because it requires predefined ports.

Note: One can limit this to a single port, just be sure to enable both TCP and UDP.

On many default configurations, when using iptables with connection tracking (conntrack) set to drop "INVALID" packets, sometimes a great deal of legitimate torrent traffic (especially DHT traffic) is dropped as "invalid." This is typically caused by either conntrack's memory restrictions, or from long periods between packets among peers (see [1] towards the bottom and [2]). Symptoms of this problem include torrents not seeding, especially when the torrent client has been active for more than a day or two continuously, and consistently low overhead traffic (in one experience, less than 3KiB/s in either in or out) with DHT enabled, even when deluge/libtorrent has been continuously running for more than forty-eight hours and many torrents are active. For this reason, it may be necessary to disable connection tracking of all torrent traffic for optimal performance, even with the listening ports set to ACCEPT (as the causes for dropping INVALID packets, for instance conntrack's memory problems, may supercede any rules to accept traffic to/from those ports).

To fully turn off connection tracking for torrents, specify ports for both Incoming and Outgoing traffic in Deluge, for instance, 56881-56889 for incoming connections and 56890-57200 for outgoing connections.

Note: Limiting incoming connections is not recommended with libtorrent as this will limit the ability to keep multiple connections to the same client, even for different torrents.

Then issue the following commands (after substituting the relevant port ranges):

# iptables -t raw -I PREROUTING -p udp --dport 56881:57200 -j NOTRACK
# iptables -t raw -I OUTPUT -p udp --sport 56881:57200 -j NOTRACK
# iptables -t raw -I PREROUTING -p tcp --dport 56881:57200 -j NOTRACK
# iptables -t raw -I OUTPUT -p tcp --sport 56881:57200 -j NOTRACK
# iptables -I INPUT -p icmp --icmp-type 3 -j ACCEPT
# iptables -I INPUT -p icmp --icmp-type 4 -j ACCEPT
# iptables -I INPUT -p icmp --icmp-type 11 -j ACCEPT
# iptables -I INPUT -p icmp --icmp-type 12 -j ACCEPT

The ICMP allowances are desirable because once connection tracking is disabled on those ports, those important ICMP messages (types 3 (Destination Unreachable), 4 (Source Quench), 11 (Time Exceeded) and 12 (Parameter Problem)) would otherwise be declared INVALID themselves (as netfilter would not know of any connections that they are associated with), and they would potentially be blocked.

Warning: A port range of 1024:65535 would break every DNS query.

Plugins

Note: Plugins should be compiled with Python2.7: e.g. $ python2.7 setup.py build.

A complete list of plugins can be found on the Deluge Wiki

ltConfig is a useful plugin that allows direct modification to libtorrent settings and has preset support.

It offers additional settings like announce_ip (IP to announce to trackers), half_open_limit (Remove maximum half-open connections limit) and more possible privacy and (seed) speedboost features.

Clients

Console

The console client can be run with:

$ deluge-console

Enter the help command for a list of available commands.

GTK+

Note: It is necessary to disable Classic Mode in Edit -> Preferences -> Interface for daemon (server) setups.

The GTK+ client can be run with:

$ deluge-gtk

or:

$ deluge

The GTK+ client has a number of useful plugins:

  • AutoAdd - Monitors directories for .torrent files
  • Blocklist - Downloads and imports an IP blocklist
  • Execute - Event-based command execution
  • Extractor - Extracts archived files upon completion (beware of random high disk I/O usage)
  • Label - Allows labels to be assigned to torrents, as well as state, tracker, and keyword filters
  • Notifications - Provides notifications (email, pop-up, blink, sound) for events as well as other plugins
  • Scheduler - Limits active torrents and their speed on a per-hour, per-day basis
  • WebUi - Allows the Web UI to be started via the GTK+ client

Web

A web-client is also provided should users not want GTK or shell-based access to the daemon.

The python2-mako dependency is needed for the web client to work. When the web client is initially started, it will create $HOME/.config/deluge/web.conf. The password in this file is hashed with SHA1 and salted. The default password is "deluge".

Just as with deluge daemon mentioned above, the web client as can be started several different ways:

  1. Systemd system service (runs as the deluge user).
  2. Systemd user service (runs as another user).
  3. Running it directly (runs as another user).
Tip: For the highest level of security, running deluge-web via the systemd system service (deluge-web.service) is recommended since the deluge user has no shell access (limited account) or other group affiliation on the host system. In addition to the security benefits of running as the non-privileged deluge user, the system service can also run at boot without the need to start Xorg or a client.

Several things to note:

  • The web client offers many of the same features of the GTK+ UI, including the plugin system.
  • It is recommended to use HTTPS for the Web client to protect against a man-in-the-middle attack.
  • Users may be greeted by a warning from the browser that the SSL certificate is untrusted. Add an exception to this in the browser to continue on. See the OpenSSL page for information on creating your own certificate.
  • If multiple users are running a daemon, the default port (8112) will need to be changed for each user.

Once running, users may connect to the web client by browsing to http://hostname:8112 or if using encryption: https://hostname:8112

System service

Deluge ships with deluge-web.service, a systemd system unit, which is used to start the Deluge Web UI. The Deluge Web UI uses a Connection Manager, allowing managing of multiple Deluge clients running under the same host or on an entirely different one. Remember to start and optionally enable the deluged service to allow the Web UI connect to the host Deluge client.

User service

A user service will allow deluge-web to run when systemd --user is started. This is accomplished by creating a user service file:

/etc/systemd/user/deluge-web.service
[Unit]
Description=Deluge Web UI
After=deluged.service

[Service]
ExecStart=/usr/bin/deluge-web --ssl

[Install]
WantedBy=default.target

The deluge user service can now be started and enabled by the user.

The deluge-web user service can also be placed in $HOME/.config/systemd/user/. See systemd/User for more information on user services.

Headless setup

Deluge is quite useful on a headless system, often referred to as a seed box, because of its client/server model. To set up deluge on a headless system, set up the daemon as shown above.

Create a user

To allow interaction with the server remotely, create a user in $HOME/.config/deluge/auth. For example:

$ echo "delugeuser:p422WoRd:10" >> $HOME/.config/deluge/auth
Note:
  • The user/password created does not have to match any system users, and to maintain good security practices it should not!
  • The user/password in this file are not hashed or salted like in the web client config.
  • The user/password must match the user/password found in /srv/deluge/.config/deluge/auth otherwise the authentication fails.

The number 10 corresponds to a level of Admin. Refer to the following table for additional values:

Level Name Level Value
None 0
Read Only 1
Normal 5
Admin 10
Note: In Deluge 1.35, these values have no effect, but multiuser options are under development.

Allow remote

The default settings disallow remote connections. Change the "allow_remote" setting in $HOME/.config/deluge/core.conf:

"allow_remote": true
Note:

1. $HOME/.config/deluge/core.conf is automatically created at the first configuration change, if it does not exist you can set the value via deluge-console:

config --set allow_remote true

2. Changes made while the service is running won't be read into the daemon, therefore, stop the service before making changes to this file.

Firewall

Open the port for remote access. The following example uses the default daemon port (58846):

# iptables -A INPUT -p tcp --dport 58846 -j ACCEPT

See iptables for more information on firewall rules.

Users behind a NAT router/firewall must forward the port to access the daemon from outside the network if this behavior is desired.

Connect

In the console client:

connect <host>[:<port>] <user> <password>

In the GTK+ client, Edit > Connection Manager > Add.

In the Web client, Connection Manager > Add.

SSH Tunnel

An SSH tunnel can be created to use an encrypted connection on any client. This requires an extra loopback address to be added, but this can be automated at boot. Without this step, the connection would be considered local. The actual command to establish an SSH tunnel cannot be automated as it requires user input. There are a few possible ways to go about doing that.

/etc/systemd/system/extra_lo_addr.service
[Unit]
Description=extra loopback address
Wants=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/ip addr add 127.0.0.2/8 dev lo
ExecStop=/sbin/ip addr del 127.0.0.2/8 dev lo

[Install]
WantedBy=multi-user.target
$ ssh -fNL 127.0.0.2:58846:localhost:58846 <ssh host>

The port 58846 should be replaced with the port the deluge server is running on and <ssh host> should be replaced with the server hosting both deluge and the SSH server.

Troubleshooting

No module named service_identity

Upon running deluged or deluge-console, you may recieve a message like the following:

:0: UserWarning: You do not have a working installation of the service_identity module: 'No module named service_identity'.  
Please install it from <https://pypi.python.org/pypi/service_identity> and make sure all of its dependencies are satisfied.  
Without the service_identity module and a recent enough pyOpenSSL to support it, Twisted can perform only rudimentary TLS 
client hostname verification.  Many valid certificate/hostname mappings may be rejected.

You may be missing python2-service-identity, which is an optional dependency to python2-twisted. See FS#43806.

Web ui .torrent upload does not work

If you are running the web ui behind a reverse proxy, you need to allow embedding for .torrent upload to work (X-Frame-Options ALLOW)

See Also