contents.lr 6.62 KB
Newer Older
1
2
3
4
_model: page
---
title: Exit Relay Configuration
---
Pili Guerra's avatar
Pili Guerra committed
5
html: two-columns-page.html
6
7
8
9
10
11
12
13
14
---
section: relay operations
---
section_id: relay-operations
---
key: 5
---
body:

emmapeel's avatar
emmapeel committed
15
We assume you read through the [relay guide](..) already. This subpage is for operators that want to turn on exiting on their relay.
16

emmapeel's avatar
emmapeel committed
17
18
19
It is recommended that you setup exit relays on servers dedicated to this purpose.
It is not recommended to install Tor exit relays on servers that you need for other services as well.
Do not mix your own traffic with your exit relay traffic.
20
21
22

## Reverse DNS and WHOIS record

emmapeel's avatar
emmapeel committed
23
Before turning your non-exit relay into an exit relay, ensure that you have set a reverse DNS record (PTR) to make it more obvious that this is a tor exit relay. Something like "tor-exit" it its name is a good start.
24

emmapeel's avatar
emmapeel committed
25
If your provider offers it, make sure your WHOIS record contains clear indications that this is a Tor exit relay.
26
27
28

## Exit Notice HTML page

emmapeel's avatar
emmapeel committed
29
30
31
To make it even more obvious that this is a Tor exit relay you should serve a Tor exit notice HTML page.
Tor can do that for you if your DirPort is on TCP port 80, you can make use of tor's DirPortFrontPage feature to display a HTML file on that port.
This file will be shown to anyone directing his browser to your Tor exit relay IP address.
32
33
34
35
36
37

```
DirPort 80
DirPortFrontPage /path/to/html/file
```

emmapeel's avatar
emmapeel committed
38
We offer a sample Tor exit notice HTML file, but you might want to adjust it to your needs:
39
40
41
42
43
44
45
https://gitweb.torproject.org/tor.git/plain/contrib/operator-tools/tor-exit-notice.html

Here are some more tips for running a reliable exit relay:
https://blog.torproject.org/tips-running-exit-node

## Exit Policy

emmapeel's avatar
emmapeel committed
46
47
48
49
Defining the [exit policy](https://www.torproject.org/docs/tor-manual.html.en#ExitPolicy) is one of the most important parts of an exit relay configuration.
The exit policy defines which destination ports you are willing to forward.
This has an impact on the amount of abuse emails you will get (less ports means less abuse emails, but an exit relay allowing only few ports is also less useful).
If you want to be a useful exit relay you must **at least allow destination ports 80 and 443**.
50

emmapeel's avatar
emmapeel committed
51
52
As a new exit relay - especially if you are new to your hoster - it is good to start with a reduced exit policy (to reduce the amount of abuse emails) and further open it up as you become more experienced.
The reduced exit policy can be found on the [ReducedExitPolicy](https://trac.torproject.org/projects/tor/wiki/doc/ReducedExitPolicy) wiki page.
53

emmapeel's avatar
emmapeel committed
54
To become an exit relay change ExitRelay from 0 to 1 in your torrc configuration file and restart the tor daemon.
55
56
57
58
59
60
61

```
ExitRelay 1
```

## DNS on Exit Relays

emmapeel's avatar
emmapeel committed
62
63
Unlike other types of relays, exit relays also do DNS resolution for Tor clients.
DNS resolution on exit relays is crucial for Tor clients, it should be reliable and fast by using caching.
64

emmapeel's avatar
emmapeel committed
65
66
* DNS resolution can have a significant impact on the performance and reliability your exit relay provides.
  Poor DNS performance will result in less traffic going through your exit relay.
67
68
69
70
71
72
* Don't use any of the big DNS resolvers as your primary or fallback DNS resolver to avoid centralization (Google, OpenDNS, Quad9, Cloudflare, 4.2.2.1-6)
* We recommend running a local caching and DNSSEC-validating resolver without using any forwarders (specific instructions follow bellow for each operating systems)
* if you want to add a second DNS resolver as a fallback to your /etc/resolv.conf configuration, try to choose a resolver within your autonomous system and make sure it is not your first entry in that file (the first entry should be your local resolver)
* if a local resolver like unbound is not an option for you try to use a resolver that your provider runs in the same autonomous system (to find out if an IP address is in the same AS as your relay, you can look it up, using for example https://bgp.he.net).
* try to avoid adding too many resolvers to your /etc/resolv.conf file to limit exposure on an AS-level (try to not use more than two entries)

emmapeel's avatar
emmapeel committed
73
74
75
There are multiple options for DNS server software, unbound has become a popular one but **feel free to use any other you are comfortable with**.
When choosing your DNS resolver software try to ensure it supports DNSSEC validation and QNAME minimisation (RFC7816).
In every case the software should be installed using the OS package manager to ensure it is updated with the rest of the system.
76

emmapeel's avatar
emmapeel committed
77
By using your own DNS resolver you are less vulnerable to DNS-based censorship that your upstream resolver might impose.
78

emmapeel's avatar
emmapeel committed
79
Here follow specific instructions on how to install and configure unbound on your exit - a DNSSEC-validating and caching resolver. unbound has many configuration and tuning nobs but we try to keep these instructions as simple and short as possible and the basic setup will do just fine for most operators.
80

emmapeel's avatar
emmapeel committed
81
After switching to unbound verify it works as expected by resolving a valid hostname, if it does not work, you can restore the old resolv.conf file.
82
83
84

### Debian/Ubuntu

emmapeel's avatar
emmapeel committed
85
The following 3 commands install unbound, backup your DNS configuration and tell the system to use the local unbound:
86
87
88
89
90
91
92
93
94
95
96
97
98

```
apt install unbound
cp /etc/resolv.conf /etc/resolv.conf.backup
echo nameserver 127.0.0.1 > /etc/resolv.conf
```

To avoid that the configuration gets changed (for example by the DHCP client):

```
chattr +i /etc/resolv.conf
```

emmapeel's avatar
emmapeel committed
99
100
The Debian configuration ships with QNAME minimisation (RFC7816) enabled by default so you don't need to enable it explicitly.
The unbound resolver you just installed does also DNSSEC validation.
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143

### CentOS/RHEL

Install the unbound package:

```
yum install unbound
```

in /etc/unbound/unbound.conf replace the line

```
# qname-minimisation: no
```

with:

```
qname-minimisation: yes
```

enable and start unbound:

```
systemctl enable unbound
systemctl start unbound
```

Tell the system to use the local unbound server:

```
cp /etc/resolv.conf /etc/resolv.conf.backup
echo nameserver 127.0.0.1 > /etc/resolv.conf
```

To avoid that the configuration gets changed (for example by the DHCP client):

```
chattr +i /etc/resolv.conf
```

### FreeBSD

emmapeel's avatar
emmapeel committed
144
FreeBSD ships unbound in the base system but the one in ports is usually following upstream more closely so we install the unbound package:
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177

```
pkg install unbound
```

Replace the content in /usr/local/etc/unbound/unbound.conf with the following lines:

```
server:
	verbosity: 1
	qname-minimisation: yes
```

enable and start the unbound service:

```
sysrc unbound_enable=YES
service unbound start
```

Tell the system to use the local unbound server:

```
cp /etc/resolv.conf /etc/resolv.conf.backup
echo nameserver 127.0.0.1 > /etc/resolv.conf
```

To avoid that the configuration gets changed (for example by the DHCP client):

```
chflags schg /etc/resolv.conf
```