baumi's blog

baumi's personal blog … Linux, OS X, Windows, Random things, …

Syncthing: force local network sync

A couple of years ago i set up an owncloud server for myself. While it’s nice for small amount of files, owncloud had some disturbing limitations. I tried syncing more than a million files, and it miserably failed. The search feature would take forever, etc … Also, you always need a server to be running.

Syncthing-GTK is a wonderful alternative. It’s available for Linux, OSX, Windows and Android. Multiple clients may sync among each other, no dedicated server/storage required. It supports version handling and can handle more than 2 clients. Also, it supports chunking. If you have a small change in a big file, Syncthing will just synchronize the changes and not the whole file. I’m loving it !

In order to force local network sync, however, you need to pay some attention to the config.

Run syncthing-gtk, open settings. In Service / Server Settings:
—————————–
Service Listening Address:
tcp://0.0.0.0:22000

Port for Local Discovery:
21027

If you don’t specify 0.0.0.0 as your listening address, syncthing will only be accessible from 127.0.0.1 (i.e. your own pc) … thus other clients can’t find each other inside your local network and will use external relay servers to find each other. Untick “Global Discovery”. Don’t forget to allow incoming connections on your PC’s firewall (gufw) for port 22000 and 21027.

Because we don’t want to leak our IP address, i.e. we don’t want Syncthing to contact external servers, edit /home/yourusername/.config/syncthing/config.xml and find “relaysEnabled“. Set its value false.

When you add the second device, use “dynamic” for the address. Even though no relay servers are used, clients will find each other on your local network. Also works with dynamic internal IP addresses.

Autostart after Login:
Add an entry to “Start and Sessions” using the following command:
/usr/bin/python2 /usr/bin/syncthing-gtk -m

where -m is minimized, so the GUI won’t get launched after login …

Comments are currently closed.