1STRELAYSRV(1) Syncthing STRELAYSRV(1)
2
3
4
6 strelaysrv - Syncthing Relay Server
7
9 strelaysrv [-debug] [-ext-address=<address>] [-global-rate=<bytes/s>] [-keys=<dir>] [-listen=<listen addr>]
10 [-message-timeout=<duration>] [-nat] [-nat-lease=<duration> [-nat-renewal=<duration>]
11 [-nat-timeout=<duration>] [-network-timeout=<duration>] [-per-session-rate=<bytes/s>]
12 [-ping-interval=<duration>] [-pools=<pool addresses>] [-protocol=<string>] [-provided-by=<string>]
13 [-status-srv=<listen addr>]
14
16 Syncthing relies on a network of community-contributed relay servers.
17 Anyone can run a relay server, and it will automatically join the relay
18 pool and be available to Syncthing users. The current list of relays
19 can be found at http://relays.syncthing.net/.
20
22 -debug Enable debug output.
23
24 -ext-address=<address>
25 An optional address to advertising as being available on. Allows
26 listening on an unprivileged port with port forwarding from e.g.
27 443, and be connected to on port 443.
28
29 -global-rate=<bytes/s>
30 Global rate limit, in bytes/s.
31
32 -keys=<dir>
33 Directory where cert.pem and key.pem is stored (default “.”).
34
35 -listen=<listen addr>
36 Protocol listen address (default “:22067”).
37
38 -message-timeout=<duration>
39 Maximum amount of time we wait for relevant messages to arrive
40 (default 1m0s).
41
42 -nat Use UPnP/NAT-PMP to acquire external port mapping
43
44 -nat-lease=<duration>
45 NAT lease length in minutes (default 60)
46
47 -nat-renewal=<duration>
48 NAT renewal frequency in minutes (default 30)
49
50 -nat-timeout=<duration>
51 NAT discovery timeout in seconds (default 10)
52
53 -network-timeout=<duration>
54 Timeout for network operations between the client and the relay.
55 If no data is received between the client and the relay in this
56 period of time, the connection is terminated. Furthermore, if no
57 data is sent between either clients being relayed within this
58 period of time, the session is also terminated. (default 2m0s)
59
60 -per-session-rate=<bytes/s>
61 Per session rate limit, in bytes/s.
62
63 -ping-interval=<duration>
64 How often pings are sent (default 1m0s).
65
66 -pools=<pool addresses>
67 Comma separated list of relay pool addresses to join (default “‐
68 http://relays.syncthing.net/endpoint”). Blank to disable an‐
69 nouncement to a pool, thereby remaining a private relay.
70
71 -protocol=<string>
72 Protocol used for listening. ‘tcp’ for IPv4 and IPv6, ‘tcp4’ for
73 IPv4, ‘tcp6’ for IPv6 (default “tcp”).
74
75 -provided-by=<string>
76 An optional description about who provides the relay.
77
78 -status-srv=<listen addr>
79 Listen address for status service (blank to disable) (default
80 “:22070”). Status service is used by the relay pool server UI
81 for displaying stats (data transferred, number of clients, etc.)
82
83 Installing
84 Go to releases <https://github.com/syncthing/relaysrv/releases> and
85 download the file appropriate for your operating system. Unpacking it
86 will yield a binary called relaysrv (or relaysrv.exe on Windows).
87 Start this in whatever way you are most comfortable with; double click‐
88 ing should work in any graphical environment. At first start, relaysrv
89 will generate certificate files and database in the current directory
90 unless given flags to the contrary. It will also join the default pools
91 of relays, which means that it is publicly visible and any client can
92 connect to it. The startup message prints instructions on how to
93 change this.
94
95 The relay server can also be obtained through apt, the Debian/Ubuntu
96 package manager. Recent releases can be found at syncthing’s apt repos‐
97 itory <https://apt.syncthing.net/>. The name of the package is sync‐
98 thing-relaysrv.
99
101 Primarily, you need to decide on a directory to store the TLS key and
102 certificate and a listen port. The default listen port of 22067 works,
103 but for optimal compatibility a well known port for encrypted traffic
104 such as 443 is recommended. This may require additional setup to work
105 without running as root or a privileged user, see Running on port 443
106 as an unprivileged user below. In principle something similar to this
107 should work on a Linux/Unix system:
108
109 $ sudo useradd relaysrv
110 $ sudo mkdir /etc/relaysrv
111 $ sudo chown relaysrv /etc/relaysrv
112 $ sudo -u relaysrv /usr/local/bin/relaysrv -keys /etc/relaysrv
113
114 This creates a user relaysrv and a directory /etc/relaysrv to store the
115 keys. The keys are generated on first startup. The relay will join the
116 global relay pool, unless a -pools="" argument is given.
117
118 To make the relay server start automatically at boot, use the recom‐
119 mended procedure for your operating system.
120
121 Client configuration
122 Syncthing can be configured to use specific relay servers (exclusively
123 of the public pool) by adding the required servers to the Sync Protocol
124 Listen Address field, under Actions and Settings. The format is as fol‐
125 lows:
126 relay://<host name|IP>[:port]/?id=<relay device ID>
127
128 For example:
129 relay://private-relay-1.example.com:443/?id=ITZRNXE-YN‐
130 ROGBZ-HXTH5P7-VK5NYE5-QHRQGE2-7JQ6VNJ-KZUEDIU-5PPR5AM
131
132 The relay’s device ID is output on start-up.
133
134 Running on port 443 as an unprivileged user
135 It is recommended that you run the relay on port 443 (or another port
136 which is commonly allowed through corporate firewalls), in order to
137 maximise the chances that people are able to connect. However, binding
138 to ports below 1024 requires root privileges, and running a relay as
139 root is not recommended. Thankfully there are a couple of approaches
140 available to you.
141
142 One option is to run the relay on port 22067, and use an iptables rule
143 to forward traffic from port 443 to port 22067, for example:
144
145 iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 22067
146
147 Or, if you’re using ufw, add the following to /etc/ufw/before.rules:
148
149 *nat
150 :PREROUTING ACCEPT [0:0]
151 :POSTROUTING ACCEPT [0:0]
152
153 -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 22067
154
155 COMMIT
156
157 You will need to start relaysrv with -ext-address ":443". This tells
158 relaysrv that it can be contacted on port 443, even though it is lis‐
159 tening on port 22067. You will also need to let both port 443 and 22067
160 through your firewall.
161
162 Another option is described here <https://wiki.apache.org/httpd/Non‐
163 RootPortBinding>, although your mileage may vary.
164
166 The relay server listens on two ports by default. One for data connec‐
167 tions and the other for providing public statistics at
168 http://relays.syncthing.net/. The firewall, such as iptables, must
169 permit incoming TCP connections to the following ports:
170
171 • Data port: 22067/tcp overridden with -listen and advertised with
172 -ext-address
173
174 • Status port: 22070/tcp overridden with -status-srv
175
176 Runtime iptables rules to allow access to the default ports:
177
178 iptables -I INPUT -p tcp --dport 22067 -j ACCEPT
179 iptables -I INPUT -p tcp --dport 22070 -j ACCEPT
180
181 Please consult Linux distribution documentation to persist firewall
182 rules.
183
185 syncthing-relay(7), syncthing-faq(7), syncthing-networking(7)
186
188 The Syncthing Authors
189
191 2014-2019, The Syncthing Authors
192
193
194
195
196v1 Apr 15, 2021 STRELAYSRV(1)