strelaysrv.1 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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" "Sep 14, 2022" "v1.21.0" "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>] [\-protocol=<string>] [\-provided\-by=<string>]
  43. [\-status\-srv=<listen addr>]
  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 \-protocol=<string>
  136. Protocol used for listening. ‘tcp’ for IPv4 and IPv6, ‘tcp4’ for IPv4, ‘tcp6’ for IPv6 (default “tcp”).
  137. .UNINDENT
  138. .INDENT 0.0
  139. .TP
  140. .B \-provided\-by=<string>
  141. An optional description about who provides the relay.
  142. .UNINDENT
  143. .INDENT 0.0
  144. .TP
  145. .B \-status\-srv=<listen addr>
  146. Listen address for status service (blank to disable) (default “:22070”).
  147. Status service is used by the relay pool server UI for displaying stats (data transferred, number of clients, etc.)
  148. .UNINDENT
  149. .SS Installing
  150. .sp
  151. Go to \fI\%releases\fP <\fBhttps://github.com/syncthing/relaysrv/releases\fP> and
  152. download the file appropriate for your operating system. Unpacking it will
  153. yield a binary called \fBstrelaysrv\fP (or \fBstrelaysrv.exe\fP on Windows).
  154. Start this in whatever way you are most comfortable with; double clicking
  155. should work in any graphical environment. At first start, strelaysrv will
  156. generate certificate files and database in the current directory unless
  157. given flags to the contrary. It will also join the default pools of relays,
  158. which means that it is publicly visible and any client can connect to it.
  159. The startup message prints instructions on how to change this.
  160. .sp
  161. The relay server can also be obtained through apt, the Debian/Ubuntu package
  162. manager. Recent releases can be found at syncthing’s
  163. \fI\%apt repository\fP <\fBhttps://apt.syncthing.net/\fP>\&. The name of the package is
  164. syncthing\-relaysrv.
  165. .SH SETTING UP
  166. .sp
  167. Primarily, you need to decide on a directory to store the TLS key and
  168. certificate and a listen port. The default listen port of 22067 works, but for
  169. optimal compatibility a well known port for encrypted traffic such as 443 is
  170. recommended. This may require additional setup to work without running
  171. as root or a privileged user, see \fI\%Running on port 443 as an unprivileged user\fP
  172. below. In principle something similar to this should work on a Linux/Unix
  173. system:
  174. .INDENT 0.0
  175. .INDENT 3.5
  176. .sp
  177. .nf
  178. .ft C
  179. $ sudo useradd strelaysrv
  180. $ sudo mkdir /etc/strelaysrv
  181. $ sudo chown strelaysrv /etc/strelaysrv
  182. $ sudo \-u strelaysrv /usr/local/bin/strelaysrv \-keys /etc/strelaysrv
  183. .ft P
  184. .fi
  185. .UNINDENT
  186. .UNINDENT
  187. .sp
  188. This creates a user \fBstrelaysrv\fP and a directory \fB/etc/strelaysrv\fP to store
  189. the keys. The keys are generated on first startup. The relay will join the
  190. global relay pool, unless a \fB\-pools=""\fP argument is given.
  191. .sp
  192. To make the relay server start automatically at boot, use the recommended
  193. procedure for your operating system.
  194. .SS Client configuration
  195. .sp
  196. 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:
  197. .INDENT 0.0
  198. .INDENT 3.5
  199. .sp
  200. .nf
  201. .ft C
  202. relay://<host name|IP>[:port]/?id=<relay device ID>
  203. .ft P
  204. .fi
  205. .UNINDENT
  206. .UNINDENT
  207. .sp
  208. For example:
  209. .INDENT 0.0
  210. .INDENT 3.5
  211. .sp
  212. .nf
  213. .ft C
  214. relay://private\-relay\-1.example.com:443/?id=ITZRNXE\-YNROGBZ\-HXTH5P7\-VK5NYE5\-QHRQGE2\-7JQ6VNJ\-KZUEDIU\-5PPR5AM
  215. .ft P
  216. .fi
  217. .UNINDENT
  218. .UNINDENT
  219. .sp
  220. The relay’s device ID is output on start\-up.
  221. .SS Running on port 443 as an unprivileged user
  222. .sp
  223. It is recommended that you run the relay on port 443 (or another port which is
  224. commonly allowed through corporate firewalls), in order to maximise the chances
  225. that people are able to connect. However, binding to ports below 1024 requires
  226. root privileges, and running a relay as root is not recommended. Thankfully
  227. there are a couple of approaches available to you.
  228. .sp
  229. One option is to run the relay on port 22067, and use an \fBiptables\fP rule
  230. to forward traffic from port 443 to port 22067, for example:
  231. .INDENT 0.0
  232. .INDENT 3.5
  233. .sp
  234. .nf
  235. .ft C
  236. iptables \-t nat \-A PREROUTING \-p tcp \-\-dport 443 \-j REDIRECT \-\-to\-port 22067
  237. .ft P
  238. .fi
  239. .UNINDENT
  240. .UNINDENT
  241. .sp
  242. Or, if you’re using \fBufw\fP, add the following to \fB/etc/ufw/before.rules\fP:
  243. .INDENT 0.0
  244. .INDENT 3.5
  245. .sp
  246. .nf
  247. .ft C
  248. *nat
  249. :PREROUTING ACCEPT [0:0]
  250. :POSTROUTING ACCEPT [0:0]
  251. \-A PREROUTING \-p tcp \-\-dport 443 \-j REDIRECT \-\-to\-port 22067
  252. COMMIT
  253. .ft P
  254. .fi
  255. .UNINDENT
  256. .UNINDENT
  257. .sp
  258. You will need to start \fBstrelaysrv\fP with \fB\-ext\-address ":443"\fP\&. This tells
  259. \fBstrelaysrv\fP that it can be contacted on port 443, even though it is listening
  260. on port 22067. You will also need to let both port 443 and 22067 through your
  261. firewall.
  262. .sp
  263. Another option is \fI\%described here\fP <\fBhttps://wiki.apache.org/httpd/NonRootPortBinding\fP>,
  264. although your mileage may vary.
  265. .SH FIREWALL CONSIDERATIONS
  266. .sp
  267. The relay server listens on two ports by default. One for data connections and the other
  268. for providing public statistics at \fI\%https://relays.syncthing.net/\fP\&. The firewall, such as
  269. \fBiptables\fP, must permit incoming TCP connections to the following ports:
  270. .INDENT 0.0
  271. .IP \(bu 2
  272. Data port: \fB22067/tcp\fP overridden with \fB\-listen\fP and advertised with \fB\-ext\-address\fP
  273. .IP \(bu 2
  274. Status port: \fB22070/tcp\fP overridden with \fB\-status\-srv\fP
  275. .UNINDENT
  276. .sp
  277. Runtime \fBiptables\fP rules to allow access to the default ports:
  278. .INDENT 0.0
  279. .INDENT 3.5
  280. .sp
  281. .nf
  282. .ft C
  283. iptables \-I INPUT \-p tcp \-\-dport 22067 \-j ACCEPT
  284. iptables \-I INPUT \-p tcp \-\-dport 22070 \-j ACCEPT
  285. .ft P
  286. .fi
  287. .UNINDENT
  288. .UNINDENT
  289. .sp
  290. Please consult Linux distribution documentation to persist firewall rules.
  291. .SH SEE ALSO
  292. .sp
  293. \fBsyncthing\-relay(7)\fP, \fBsyncthing\-faq(7)\fP,
  294. \fBsyncthing\-networking(7)\fP
  295. .SH AUTHOR
  296. The Syncthing Authors
  297. .SH COPYRIGHT
  298. 2014-2019, The Syncthing Authors
  299. .\" Generated by docutils manpage writer.
  300. .