Configure different folders per network topology (WAN vs LAN) due to bandwidth constraints

Hello! Syncthing - fantastic product. Really.

Specific Question. I move between locations with my laptop; some location has very limited bandwidth, other, not so much.

As such, I would like to setup some directories (ex: documents) to sync between devices as per usual - no matter if I am connected to the other devices via WAN or LAN.

Other directories, for heavy content (ex: home videos) I would like to sync the directories only if syncthing detects the devices are on the same LAN (and not WAN).

To be clear: I know one can configure different network syncing per device; I wonder if this is possible per folder

Is this possible? I understand the GUI might not support this, but can it be configured in the xml config?

If this feature does not exist, perhaps others have similar needs?

1 Like

I don’t think that’s currently possible.

One could imagine having rate limits per folder, and those rate limits (like our other rate limits) optionally not taking effect when on LAN.

2 Likes

Thank you for the reply. My acute problem is that when I am at our offgrid location, on a sattelite hookup, it has a monthly cap download limit which is pretty harsh. If a family member in the city dumps few gigs of family videos from their phones into a shared folder, syncthing will be downloading it onto my laptop when I am offgrid, and it will eat away on my monthly download cap.

I expand on this because it is a real world scenario. I know a lot of offgriders are really into the FOSS scene, and I imagine they might run into similar problems.

So setting the rate of transfer would not help much. I would imagine since there is setting of how to connect per device, it could be done per folder, but of course I imagine it would have to gain prominence in the list of features to implement…

I am racking my brain on how to solve this…some hack…but nothing comes to mind

1 Like

I can see two possible ugly workarounds. The first is to simply pause the folders you don’t want to sync when you are at your remote location. Starting Syncthing as syncthing -paused might help as you then get an always-paused starting point so no unpleasant surprises. If you have a better indicator for when you are off grid you might script something to pause the folders automatically when this is detected.

The other is to have two separate devices on the other side, one with everything that is only reachable over LAN (use IP ACLs or specific device address) and one with only a subset of folders that is reachable always.

2 Likes

Appreciate the thinking out of the box, thank you. I will mull it over.

One more question came to mind.

Using external scripting - I could perhaps somehow detect I am on a different router/network. Don’t know how yet, but I could imagine there could be a way.

I recall one can pause individual folders, correct? If so, would this scripting exercise involve seeking out the folders in question in the xml syncthing config and writing a node or property to pause the folder? If so, when is the xml config read? Meaning, if I wrote into the config this new status, how would I make syncthing be aware of the change?

You need to post the config as json to the rest api, or modify xml while syncthing is not running.

3 Likes

I have a very similar use case and use two pairs of Syncthing instances. The “LAN Only” instance pairs have relaying, UPnP and global discovery disabled and have their addresses statically set in the device config. They run on different data, web GUI and legacy broadcast ports from the regular Syncthing instance. This approach works reliably, albeit with additional overhead.

1 Like

Aha, that is very interesting. So if I get you - you setup two deamon instances, each running with different user? Or same user, but you launch it twice? How did you accomplish to invoke at startup two different instances (all our machines are linux :slight_smile: )?

I have to admit that this entire issue is extremely important to me, as it seems to be to you. Home videos really kill the entire concept of syncing for me if I cnnot have this LAN/WAN distinction. Otherwise, I am looking at using external HDDs and then syncing those HDDs using some sort of compare/backup software - all of which is awful solution.

Some advice on running two instances would be greatly appreciated, because I rather suffer the additional (albeit small) overhead and have a great solution.

Sure, in the future I may run some sort of beagle board or another such small board with a USB3 external HDD and then truly have two devices…but I am not there yet.

Cheers!

Yes, two daemons, in my case they’re both running on Windows as the same user. Launched twice (using the SyncTrayzor wrapper), they’re two pairs of independent services. How you’d accomplish this on Linux I’m not sure, but I have every certainty that it’s possible.

As I mentioned you’ll need to configure the second instance to use a different Syncthing port, web GUI port and different IPv4 local discovery ports. Disable relaying to prevent the WAN being used, UPnP as it’s unnecessary inside a LAN and since I used static addresses, global discovery. Incidentally I used the devices’ IPv6 link-local addresses since these won’t change.

Appreciate all the tips. I will likely go down this route, but I am unsure on how to launch two instances of syncthing under linux.

I already created a separate user for syncthing and start the deamon in linux on startup. What I wonder, is how to run multiple instances. Does one simply create a secondary entry in whatever autostart system (systemd, etc) and for each instance deamon, run it using a different username, so as to be able to have 2 different xml configurations? That’s the only way I can see to make this work. Any other ideas or did I get it wrong?

Note: I do not like the idea of running syncthing with the logged-in user for few reasons. And it seems to me, anyways, if I did that, I definitely would not be able to run multiple instances running same user, correct? Because how would each instance be using a different config file? Or, can a different config file be specified as a command line parameter, and passing thus different paths to 2 different config files, one per each deamon invocation?

The other way round on a roaming Linux box could be to to use iptables or a alternative to block in & out connection over wan to and from home server on syncthing ports only when you are on WAN

Exactly. It’s the -home parameter.

Interesting approach; I wonder if syncthing then won’t generate a lot of noise in the log files however complaining of not being able to connect. I admit, it is a solution, but I think the one launching syncthing as two separate deamons is perhaps a bit cleaner approach from maintenance perspective and readability of log files. Just my opinion.

Still, I appreciate all the feedback here, I really do as I hope it serves others that might be looking for similar solution. Others might appreciate a different solution than mine.

Thank you! I was actually wondering if I would have to create a separate linux user, put a separate config into a home folder and invoke two deamons, one per different user.

I did come across the home folder and was wondering if that was a way to go. I was unsure if invoking the deamon twice would spawn two different threads and thus be able to feed two different config files via the home parameter. It seems you are confirming one can indeed spawn two instances of the same deamon, for the same linux user (I use a dedicated user for syncthing) using two different home parameters.

Wonderful! I will test this and think this is the winning approach for me.

Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.