strelaysrv.1 9.7 KB

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