strelaysrv.1 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .
  4. .nr rst2man-indent-level 0
  5. .
  6. .de1 rstReportMargin
  7. \\$1 \\n[an-margin]
  8. level \\n[rst2man-indent-level]
  9. level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
  10. -
  11. \\n[rst2man-indent0]
  12. \\n[rst2man-indent1]
  13. \\n[rst2man-indent2]
  14. ..
  15. .de1 INDENT
  16. .\" .rstReportMargin pre:
  17. . RS \\$1
  18. . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
  19. . nr rst2man-indent-level +1
  20. .\" .rstReportMargin post:
  21. ..
  22. .de UNINDENT
  23. . RE
  24. .\" indent \\n[an-margin]
  25. .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
  26. .nr rst2man-indent-level -1
  27. .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
  28. .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
  29. ..
  30. .TH "STRELAYSRV" "1" "Jun 02, 2024" "v1.27.7" "Syncthing"
  31. .SH NAME
  32. strelaysrv \- Syncthing Relay Server
  33. .SH SYNOPSIS
  34. .INDENT 0.0
  35. .INDENT 3.5
  36. .sp
  37. .EX
  38. strelaysrv [\-debug] [\-ext\-address=<address>] [\-global\-rate=<bytes/s>] [\-keys=<dir>] [\-listen=<listen addr>]
  39. [\-message\-timeout=<duration>] [\-nat] [\-nat\-lease=<duration>] [\-nat\-renewal=<duration>]
  40. [\-nat\-timeout=<duration>] [\-network\-timeout=<duration>] [\-per\-session\-rate=<bytes/s>]
  41. [\-ping\-interval=<duration>] [\-pools=<pool addresses>] [\-pprof] [\-protocol=<string>]
  42. [\-provided\-by=<string>] [\-status\-srv=<listen addr>] [\-token=<string>] [\-version]
  43. .EE
  44. .UNINDENT
  45. .UNINDENT
  46. .SH DESCRIPTION
  47. .sp
  48. Syncthing relies on a network of community\-contributed relay servers. Anyone
  49. can run a relay server, and it will automatically join the relay pool and be
  50. available to Syncthing users. The current list of relays can be found at
  51. \X'tty: link https://relays.syncthing.net/'\fI\%https://relays.syncthing.net/\fP\X'tty: link'\&.
  52. .SH OPTIONS
  53. .INDENT 0.0
  54. .TP
  55. .B \-debug
  56. Enable debug output.
  57. .UNINDENT
  58. .INDENT 0.0
  59. .TP
  60. .B \-ext\-address=<address>
  61. An optional address to advertising as being available on. Allows listening
  62. on an unprivileged port with port forwarding from e.g. 443, and be
  63. connected to on port 443.
  64. .UNINDENT
  65. .INDENT 0.0
  66. .TP
  67. .B \-global\-rate=<bytes/s>
  68. Global rate limit, in bytes/s.
  69. .UNINDENT
  70. .INDENT 0.0
  71. .TP
  72. .B \-keys=<dir>
  73. Directory where cert.pem and key.pem is stored (default “.”).
  74. .UNINDENT
  75. .INDENT 0.0
  76. .TP
  77. .B \-listen=<listen addr>
  78. Protocol listen address (default “:22067”).
  79. .UNINDENT
  80. .INDENT 0.0
  81. .TP
  82. .B \-message\-timeout=<duration>
  83. Maximum amount of time we wait for relevant messages to arrive (default 1m0s).
  84. .UNINDENT
  85. .INDENT 0.0
  86. .TP
  87. .B \-nat
  88. Use UPnP/NAT\-PMP to acquire external port mapping
  89. .UNINDENT
  90. .INDENT 0.0
  91. .TP
  92. .B \-nat\-lease=<duration>
  93. NAT lease length in minutes (default 60)
  94. .UNINDENT
  95. .INDENT 0.0
  96. .TP
  97. .B \-nat\-renewal=<duration>
  98. NAT renewal frequency in minutes (default 30)
  99. .UNINDENT
  100. .INDENT 0.0
  101. .TP
  102. .B \-nat\-timeout=<duration>
  103. NAT discovery timeout in seconds (default 10)
  104. .UNINDENT
  105. .INDENT 0.0
  106. .TP
  107. .B \-network\-timeout=<duration>
  108. Timeout for network operations between the client and the relay. If no data
  109. is received between the client and the relay in this period of time, the
  110. connection is terminated. Furthermore, if no data is sent between either
  111. clients being relayed within this period of time, the session is also
  112. terminated. (default 2m0s)
  113. .UNINDENT
  114. .INDENT 0.0
  115. .TP
  116. .B \-per\-session\-rate=<bytes/s>
  117. Per session rate limit, in bytes/s.
  118. .UNINDENT
  119. .INDENT 0.0
  120. .TP
  121. .B \-ping\-interval=<duration>
  122. How often pings are sent (default 1m0s).
  123. .UNINDENT
  124. .INDENT 0.0
  125. .TP
  126. .B \-pools=<pool addresses>
  127. Comma separated list of relay pool addresses to join (default
  128. “\X'tty: link https://relays.syncthing.net/endpoint'\fI\%https://relays.syncthing.net/endpoint\fP\X'tty: link'”). Blank to disable announcement to
  129. a pool, thereby remaining a private relay.
  130. .UNINDENT
  131. .INDENT 0.0
  132. .TP
  133. .B \-pprof
  134. Enable the built in profiling on the status server
  135. .UNINDENT
  136. .INDENT 0.0
  137. .TP
  138. .B \-protocol=<string>
  139. Protocol used for listening. ‘tcp’ for IPv4 and IPv6, ‘tcp4’ for IPv4, ‘tcp6’ for IPv6 (default “tcp”).
  140. .UNINDENT
  141. .INDENT 0.0
  142. .TP
  143. .B \-provided\-by=<string>
  144. An optional description about who provides the relay.
  145. .UNINDENT
  146. .INDENT 0.0
  147. .TP
  148. .B \-status\-srv=<listen addr>
  149. Listen address for status service (blank to disable) (default “:22070”).
  150. Status service is used by the relay pool server UI for displaying stats (data transferred, number of clients, etc.)
  151. .UNINDENT
  152. .INDENT 0.0
  153. .TP
  154. .B \-token=<string>
  155. Token to restrict access to the relay (optional). Disables joining any pools.
  156. .UNINDENT
  157. .INDENT 0.0
  158. .TP
  159. .B \-version
  160. Show version
  161. .UNINDENT
  162. .SS Installing
  163. .sp
  164. Go to \X'tty: link https://github.com/syncthing/relaysrv/releases'\fI\%releases\fP <\fBhttps://github.com/syncthing/relaysrv/releases\fP>\X'tty: link' and
  165. download the file appropriate for your operating system. Unpacking it will
  166. yield a binary called \fBstrelaysrv\fP (or \fBstrelaysrv.exe\fP on Windows).
  167. Start this in whatever way you are most comfortable with; double clicking
  168. should work in any graphical environment. At first start, strelaysrv will
  169. generate certificate files and database in the current directory unless
  170. given flags to the contrary. It will also join the default pools of relays,
  171. which means that it is publicly visible and any client can connect to it.
  172. The startup message prints instructions on how to change this.
  173. .sp
  174. The relay server can also be obtained through apt, the Debian/Ubuntu package
  175. manager. Recent releases can be found at syncthing’s
  176. \X'tty: link https://apt.syncthing.net/'\fI\%apt repository\fP <\fBhttps://apt.syncthing.net/\fP>\X'tty: link'\&. The name of the package is
  177. syncthing\-relaysrv.
  178. .SH SETTING UP
  179. .sp
  180. Primarily, you need to decide on a directory to store the TLS key and
  181. certificate and a listen port. The default listen port of 22067 works, but for
  182. optimal compatibility a well known port for encrypted traffic such as 443 is
  183. recommended. This may require additional setup to work without running
  184. as root or a privileged user, see \fI\%Running on port 443 as an unprivileged user\fP
  185. below. In principle something similar to this should work on a Linux/Unix
  186. system:
  187. .INDENT 0.0
  188. .INDENT 3.5
  189. .sp
  190. .EX
  191. $ sudo useradd strelaysrv
  192. $ sudo mkdir /etc/strelaysrv
  193. $ sudo chown strelaysrv /etc/strelaysrv
  194. $ sudo \-u strelaysrv /usr/local/bin/strelaysrv \-keys /etc/strelaysrv
  195. .EE
  196. .UNINDENT
  197. .UNINDENT
  198. .sp
  199. This creates a user \fBstrelaysrv\fP and a directory \fB/etc/strelaysrv\fP to store
  200. the keys. The keys are generated on first startup. The relay will join the
  201. global relay pool, unless a \fB\-pools=\(dq\(dq\fP argument is given.
  202. .sp
  203. To make the relay server start automatically at boot, use the recommended
  204. procedure for your operating system.
  205. .SS Client configuration
  206. .sp
  207. Syncthing can be configured to use specific relay servers (exclusively of the public pool) by adding the required servers to the Sync Protocol Listen Address field, under Actions and Settings. The format is as follows:
  208. .INDENT 0.0
  209. .INDENT 3.5
  210. .sp
  211. .EX
  212. relay://<host name|IP>[:port]/?id=<relay device ID>
  213. .EE
  214. .UNINDENT
  215. .UNINDENT
  216. .sp
  217. For example:
  218. .INDENT 0.0
  219. .INDENT 3.5
  220. .sp
  221. .EX
  222. relay://private\-relay\-1.example.com:443/?id=ITZRNXE\-YNROGBZ\-HXTH5P7\-VK5NYE5\-QHRQGE2\-7JQ6VNJ\-KZUEDIU\-5PPR5AM
  223. .EE
  224. .UNINDENT
  225. .UNINDENT
  226. .sp
  227. The relay’s device ID is output on start\-up.
  228. .SS Running on port 443 as an unprivileged user
  229. .sp
  230. It is recommended that you run the relay on port 443 (or another port which is
  231. commonly allowed through corporate firewalls), in order to maximise the chances
  232. that people are able to connect. However, binding to ports below 1024 requires
  233. root privileges, and running a relay as root is not recommended. Thankfully
  234. there are a couple of approaches available to you.
  235. .sp
  236. One option is to run the relay on port 22067, and use an \fBiptables\fP rule
  237. to forward traffic from port 443 to port 22067, for example:
  238. .INDENT 0.0
  239. .INDENT 3.5
  240. .sp
  241. .EX
  242. iptables \-t nat \-A PREROUTING \-p tcp \-\-dport 443 \-j REDIRECT \-\-to\-port 22067
  243. .EE
  244. .UNINDENT
  245. .UNINDENT
  246. .sp
  247. Or, if you’re using \fBufw\fP, add the following to \fB/etc/ufw/before.rules\fP:
  248. .INDENT 0.0
  249. .INDENT 3.5
  250. .sp
  251. .EX
  252. *nat
  253. :PREROUTING ACCEPT [0:0]
  254. :POSTROUTING ACCEPT [0:0]
  255. \-A PREROUTING \-p tcp \-\-dport 443 \-j REDIRECT \-\-to\-port 22067
  256. COMMIT
  257. .EE
  258. .UNINDENT
  259. .UNINDENT
  260. .sp
  261. You will need to start \fBstrelaysrv\fP with \fB\-ext\-address \(dq:443\(dq\fP\&. This tells
  262. \fBstrelaysrv\fP that it can be contacted on port 443, even though it is listening
  263. on port 22067. You will also need to let both port 443 and 22067 through your
  264. firewall.
  265. .sp
  266. Another option is \X'tty: link https://wiki.apache.org/httpd/NonRootPortBinding'\fI\%described here\fP <\fBhttps://wiki.apache.org/httpd/NonRootPortBinding\fP>\X'tty: link',
  267. although your mileage may vary.
  268. .SH FIREWALL CONSIDERATIONS
  269. .sp
  270. The relay server listens on two ports by default. One for data connections and the other
  271. for providing public statistics at \X'tty: link https://relays.syncthing.net/'\fI\%https://relays.syncthing.net/\fP\X'tty: link'\&. The firewall, such as
  272. \fBiptables\fP, must permit incoming TCP connections to the following ports:
  273. .INDENT 0.0
  274. .IP \(bu 2
  275. Data port: \fB22067/tcp\fP overridden with \fB\-listen\fP and advertised with \fB\-ext\-address\fP
  276. .IP \(bu 2
  277. Status port: \fB22070/tcp\fP overridden with \fB\-status\-srv\fP
  278. .UNINDENT
  279. .sp
  280. Runtime \fBiptables\fP rules to allow access to the default ports:
  281. .INDENT 0.0
  282. .INDENT 3.5
  283. .sp
  284. .EX
  285. iptables \-I INPUT \-p tcp \-\-dport 22067 \-j ACCEPT
  286. iptables \-I INPUT \-p tcp \-\-dport 22070 \-j ACCEPT
  287. .EE
  288. .UNINDENT
  289. .UNINDENT
  290. .sp
  291. Please consult Linux distribution documentation to persist firewall rules.
  292. .SH ACCESS CONTROL FOR PRIVATE RELAYS
  293. .sp
  294. Added in version 1.22.1.
  295. .sp
  296. Private relays can be configured to only accept connections from peers in possession of a shared secret.
  297. To configure this use the \fB\-token\fP option:
  298. .sp
  299. $ strelaysrv \-token=mySecretToken
  300. .sp
  301. Then configure your Syncthing devices to send the token when joining the relay:
  302. .INDENT 0.0
  303. .INDENT 3.5
  304. .sp
  305. .EX
  306. relay://<host name|IP>[:port]/?id=<relay device ID>&token=mySecretToken
  307. .EE
  308. .UNINDENT
  309. .UNINDENT
  310. .SH SEE ALSO
  311. .sp
  312. \fBsyncthing\-relay(7)\fP, \fBsyncthing\-faq(7)\fP,
  313. \fBsyncthing\-networking(7)\fP
  314. .SH AUTHOR
  315. The Syncthing Authors
  316. .SH COPYRIGHT
  317. 2014-2019, The Syncthing Authors
  318. .\" Generated by docutils manpage writer.
  319. .