STRELAYSRV(1) | Syncthing | STRELAYSRV(1) |
strelaysrv - Syncthing Relay Server
strelaysrv [-debug] [-ext-address=<address>] [-global-rate=<bytes/s>] [-keys=<dir>] [-listen=<listen addr>]
[-message-timeout=<duration>] [-nat] [-nat-lease=<duration> [-nat-renewal=<duration>]
[-nat-timeout=<duration>] [-network-timeout=<duration>] [-per-session-rate=<bytes/s>]
[-ping-interval=<duration>] [-pools=<pool addresses>] [-protocol=<string>] [-provided-by=<string>]
[-status-srv=<listen addr>]
Syncthing relies on a network of community-contributed relay servers. Anyone can run a relay server, and it will automatically join the relay pool and be available to Syncthing users. The current list of relays can be found at http://relays.syncthing.net/.
Primarily, you need to decide on a directory to store the TLS key and certificate and a listen port. The default listen port of 22067 works, but for optimal compatibility a well known port for encrypted traffic such as 443 is recommended. This may require additional setup to work without running as root or a privileged user, see Running on port 443 as an unprivileged user below. In principle something similar to this should work on a Linux/Unix system:
$ sudo useradd relaysrv $ sudo mkdir /etc/relaysrv $ sudo chown relaysrv /etc/relaysrv $ sudo -u relaysrv /usr/local/bin/relaysrv -keys /etc/relaysrv
This creates a user relaysrv and a directory /etc/relaysrv to store the keys. The keys are generated on first startup. The relay will join the global relay pool, unless a -pools="" argument is given.
To make the relay server start automatically at boot, use the recommended procedure for your operating system.
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:
For example:
The relay’s device ID is output on start-up.
It is recommended that you run the relay on port 443 (or another port which is commonly allowed through corporate firewalls), in order to maximise the chances that people are able to connect. However, binding to ports below 1024 requires root privileges, and running a relay as root is not recommended. Thankfully there are a couple of approaches available to you.
One option is to run the relay on port 22067, and use an iptables rule to forward traffic from port 443 to port 22067, for example:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 22067
Or, if you’re using ufw, add the following to /etc/ufw/before.rules:
*nat :PREROUTING ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 22067 COMMIT
You will need to start relaysrv with -ext-address ":443". This tells relaysrv that it can be contacted on port 443, even though it is listening on port 22067. You will also need to let both port 443 and 22067 through your firewall.
Another option is described here <https://wiki.apache.org/httpd/NonRootPortBinding>, although your mileage may vary.
The relay server listens on two ports by default. One for data connections and the other for providing public statistics at http://relays.syncthing.net/. The firewall, such as iptables, must permit incoming TCP connections to the following ports:
Runtime iptables rules to allow access to the default ports:
iptables -I INPUT -p tcp --dport 22067 -j ACCEPT iptables -I INPUT -p tcp --dport 22070 -j ACCEPT
Please consult Linux distribution documentation to persist firewall rules.
syncthing-relay(7), syncthing-faq(7), syncthing-networking(7)
The Syncthing Authors
2014-2018, The Syncthing Authors
November 5, 2018 | v0.14 |