strelaysrv.1 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH "STRELAYSRV" "1" "Dec 05, 2020" "v1" "Syncthing"
  4. .SH NAME
  5. strelaysrv \- Syncthing Relay Server
  6. .
  7. .nr rst2man-indent-level 0
  8. .
  9. .de1 rstReportMargin
  10. \\$1 \\n[an-margin]
  11. level \\n[rst2man-indent-level]
  12. level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
  13. -
  14. \\n[rst2man-indent0]
  15. \\n[rst2man-indent1]
  16. \\n[rst2man-indent2]
  17. ..
  18. .de1 INDENT
  19. .\" .rstReportMargin pre:
  20. . RS \\$1
  21. . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
  22. . nr rst2man-indent-level +1
  23. .\" .rstReportMargin post:
  24. ..
  25. .de UNINDENT
  26. . RE
  27. .\" indent \\n[an-margin]
  28. .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
  29. .nr rst2man-indent-level -1
  30. .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
  31. .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
  32. ..
  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\%http://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\%http://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. .SH SETTING UP
  150. .sp
  151. Primarily, you need to decide on a directory to store the TLS key and
  152. certificate and a listen port. The default listen port of 22067 works, but for
  153. optimal compatibility a well known port for encrypted traffic such as 443 is
  154. recommended. This may require additional setup to work without running
  155. as root or a privileged user, see \fI\%Running on port 443 as an unprivileged user\fP
  156. below. In principle something similar to this should work on a Linux/Unix
  157. system:
  158. .INDENT 0.0
  159. .INDENT 3.5
  160. .sp
  161. .nf
  162. .ft C
  163. $ sudo useradd relaysrv
  164. $ sudo mkdir /etc/relaysrv
  165. $ sudo chown relaysrv /etc/relaysrv
  166. $ sudo \-u relaysrv /usr/local/bin/relaysrv \-keys /etc/relaysrv
  167. .ft P
  168. .fi
  169. .UNINDENT
  170. .UNINDENT
  171. .sp
  172. This creates a user \fBrelaysrv\fP and a directory \fB/etc/relaysrv\fP to store
  173. the keys. The keys are generated on first startup. The relay will join the
  174. global relay pool, unless a \fB\-pools=""\fP argument is given.
  175. .sp
  176. To make the relay server start automatically at boot, use the recommended
  177. procedure for your operating system.
  178. .SS Client configuration
  179. .sp
  180. 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:
  181. .INDENT 0.0
  182. .INDENT 3.5
  183. relay://<host name|IP>[:port]/?id=<relay device ID>
  184. .UNINDENT
  185. .UNINDENT
  186. .sp
  187. For example:
  188. .INDENT 0.0
  189. .INDENT 3.5
  190. relay://private\-relay\-1.example.com:443/?id=ITZRNXE\-YNROGBZ\-HXTH5P7\-VK5NYE5\-QHRQGE2\-7JQ6VNJ\-KZUEDIU\-5PPR5AM
  191. .UNINDENT
  192. .UNINDENT
  193. .sp
  194. The relay’s device ID is output on start\-up.
  195. .SS Running on port 443 as an unprivileged user
  196. .sp
  197. It is recommended that you run the relay on port 443 (or another port which is
  198. commonly allowed through corporate firewalls), in order to maximise the chances
  199. that people are able to connect. However, binding to ports below 1024 requires
  200. root privileges, and running a relay as root is not recommended. Thankfully
  201. there are a couple of approaches available to you.
  202. .sp
  203. One option is to run the relay on port 22067, and use an \fBiptables\fP rule
  204. to forward traffic from port 443 to port 22067, for example:
  205. .INDENT 0.0
  206. .INDENT 3.5
  207. .sp
  208. .nf
  209. .ft C
  210. iptables \-t nat \-A PREROUTING \-i eth0 \-p tcp \-\-dport 443 \-j REDIRECT \-\-to\-port 22067
  211. .ft P
  212. .fi
  213. .UNINDENT
  214. .UNINDENT
  215. .sp
  216. Or, if you’re using \fBufw\fP, add the following to \fB/etc/ufw/before.rules\fP:
  217. .INDENT 0.0
  218. .INDENT 3.5
  219. .sp
  220. .nf
  221. .ft C
  222. *nat
  223. :PREROUTING ACCEPT [0:0]
  224. :POSTROUTING ACCEPT [0:0]
  225. \-A PREROUTING \-i eth0 \-p tcp \-\-dport 443 \-j REDIRECT \-\-to\-port 22067
  226. COMMIT
  227. .ft P
  228. .fi
  229. .UNINDENT
  230. .UNINDENT
  231. .sp
  232. You will need to start \fBrelaysrv\fP with \fB\-ext\-address ":443"\fP\&. This tells
  233. \fBrelaysrv\fP that it can be contacted on port 443, even though it is listening
  234. on port 22067. You will also need to let both port 443 and 22067 through your
  235. firewall.
  236. .sp
  237. Another option is \fI\%described here\fP <\fBhttps://wiki.apache.org/httpd/NonRootPortBinding\fP>,
  238. although your mileage may vary.
  239. .SH FIREWALL CONSIDERATIONS
  240. .sp
  241. The relay server listens on two ports by default. One for data connections and the other
  242. for providing public statistics at \fI\%http://relays.syncthing.net/\fP\&. The firewall, such as
  243. \fBiptables\fP, must permit incoming TCP connections to the following ports:
  244. .INDENT 0.0
  245. .IP \(bu 2
  246. Data port: \fB22067/tcp\fP overridden with \fB\-listen\fP and advertised with \fB\-ext\-address\fP
  247. .IP \(bu 2
  248. Status port: \fB22070/tcp\fP overridden with \fB\-status\-srv\fP
  249. .UNINDENT
  250. .sp
  251. Runtime \fBiptables\fP rules to allow access to the default ports:
  252. .INDENT 0.0
  253. .INDENT 3.5
  254. .sp
  255. .nf
  256. .ft C
  257. iptables \-I INPUT \-p tcp \-\-dport 22067 \-j ACCEPT
  258. iptables \-I INPUT \-p tcp \-\-dport 22070 \-j ACCEPT
  259. .ft P
  260. .fi
  261. .UNINDENT
  262. .UNINDENT
  263. .sp
  264. Please consult Linux distribution documentation to persist firewall rules.
  265. .SH SEE ALSO
  266. .sp
  267. \fBsyncthing\-relay(7)\fP, \fBsyncthing\-faq(7)\fP,
  268. \fBsyncthing\-networking(7)\fP
  269. .SH AUTHOR
  270. The Syncthing Authors
  271. .SH COPYRIGHT
  272. 2014-2019, The Syncthing Authors
  273. .\" Generated by docutils manpage writer.
  274. .