124 lines
8.8 KiB
HTML
124 lines
8.8 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title>
|
|
Syncthing Anywhere With Tailscale
|
|
- rizaldy.today
|
|
</title>
|
|
|
|
<link rel="me" href="https://edgy.social/@rizaldy">
|
|
|
|
<link rel="preconnect" href="https://unpkg.com">
|
|
<link rel="preconnect" href="https://api.fontshare.com">
|
|
<link rel="preconnect" href="https://fonts.bunny.net">
|
|
|
|
<link href="https://unpkg.com/prismjs@1.29.0/themes/prism-tomorrow.min.css" rel="stylesheet">
|
|
<link href="https://api.fontshare.com/v2/css?f[]=clash-display@1&f[]=sentient@1&display=swap" rel="stylesheet">
|
|
<link href="https://fonts.bunny.net/css?family=jetbrains-mono:400" rel="stylesheet">
|
|
|
|
<link href="/assets/css/reset.css" rel="stylesheet">
|
|
<link href="/assets/css/style.css" rel="stylesheet">
|
|
</head>
|
|
|
|
|
|
<body>
|
|
<main class="l-container">
|
|
<div class="l-fragment l-fragment--blog">
|
|
<div class="c-article">
|
|
<h1>Syncthing Anywhere With Tailscale</h1>
|
|
|
|
<p class="c-article__meta-info">
|
|
<time>Jan 04, 2022</time> •
|
|
|
|
|
|
|
|
|
|
<span class="c-article__meta-info-tag"
|
|
><a class="u-no-underline u-underline--hover" href="#tailscale">TAILSCALE</a></span
|
|
>
|
|
|
|
|
|
|
|
<span class="c-article__meta-info-tag"
|
|
><a class="u-no-underline u-underline--hover" href="#syncthing">SYNCTHING</a></span
|
|
>
|
|
|
|
|
|
</p>
|
|
|
|
<p>I don't archive data very often but when I do it must be for a very important one. On the other hand, I somewhat don't trust "cloud" providers and would avoid them as much as I can since my paranoid level is kinda high.</p>
|
|
<p>And just like everyone else, I run servers at home. The servers are not that powerful but sufficient for my needs. I have two servers run but the most important (and data-heavy) is the box with TrueNAS OS.
|
|
Previously I use NextCloud to store my data plus I could access it anywhere. NextCloud is a powerful platform with rich features, I even can run an ActivityPub-based social network there. But the client app is somewhat heavy and the server consumes more resources than I thought, plus the caching system on the client app is somewhat buggy. I can't depend my life on NextCloud, or maybe someday will.</p>
|
|
<p>I know I can use <code>rsync(1)</code> or even <code>rclone(1)</code> on my computer but they both do different jobs. I need a system to pull-and-push data not just push.</p>
|
|
<p>And don't ask me why I'm not using BTSync.</p>
|
|
<p>Then I found <a href="https://syncthing.net">Syncthing</a> somewhere. It only does one thing and probably does it well: <strong>sync data</strong>. Its tagline is <em>"Syncthing is a <strong>continuous file synchronization program</strong>. It synchronizes files between two or more computers in real time, safely protected from prying eyes. Your data is your data alone and you deserve to choose where it is stored, whether it is shared with some third party, and how it's transmitted over the internet."</em> and it really took my heart.</p>
|
|
<p>And then I installed Syncthing, used it for some time (until now), and that's why we are here.</p>
|
|
<h2>Syncing concepts</h2>
|
|
<p>Syncthing will establish direct connections between clients (peer-to-peer) as much as possible, and as we know, p2p connection is never easy. And if that's not possible, traffic is bounced through the "relay" until both computers figured out how to establish a direct connection — once again, if possible.</p>
|
|
<p>Syncthing uses <a href="https://docs.syncthing.net/dev/device-ids.html">"Device ID"</a> as an identifier so that neither party needs to know each other's IP address thanks to <a href="https://docs.syncthing.net/users/stdiscosrv.html">Global Discovery</a>. I just used the Local Discovery feature and turned the 'Enable Relaying' option off so I know the only connection made to .syncthing.net should be just sending an (anonymous) usage report, and I'm fine with that.</p>
|
|
<p>While this approach only makes my life harder, at least I know what I know even though all packets are encrypted in transit (via TLS) and are every device is authenticated by a cryptographic thing.</p>
|
|
<h2>LAN anywhere</h2>
|
|
<p>All my servers at home are almost locked-down. Only traffic to port 80 is allowed in on my WAN. Not even port forwarding because I don't know much about computer and networking security.
|
|
So I designed my home network to be limited to working only on LAN. I don't know exactly how but I just made TCP listen only to the private network. Like, If I can only visit Syncthing GUI via 192.168.1.56 then I can only visit Syncthing GUI over 192.168.1.0/24 network, on my network.</p>
|
|
<p>Speaking of my Syncthing, it's running on FreeBSD jail with a dedicated IP address from my DHCP server.</p>
|
|
<p>And as always, the only way to connect a private network over public networks is by establishing a VPN, assuming I'm not interested yet in a commercial "Zero Trust Network" solution that maybe tunnels any TCP/UDP packets through a commercial reverse proxy because the packets are not end-to-end encrypted.</p>
|
|
<p>Anyways, I use <a href="https://tailscale.com">Tailscale</a> and am a huge fan of both the team and the product. Tailscale is built on top Wireguard, and I used to use direct Wireguard until I was overwhelmed with mesh networking.</p>
|
|
<p>Using Tailscale is pretty straight forward, I don't have to manage keys; know each peer's IP address and public key, define DNS and even perform key rotation. It just works.</p>
|
|
<p>The problem is that my Syncthing is running on the FreeBSD jail and can't dial <code>devd(8)</code> in the jail whereas Tailscale needs to monitor network state changes (they have a <a href="https://github.com/tailscale/tailscale/pull/3508">workaround</a> for this! but I haven't tried it yet). Since I'm also running Tailscale on my TrueNAS, I can use <a href="https://tailscale.com/kb/1019/subnets">"subnet router"</a> which in short acts as a gateway of my physical subnet.</p>
|
|
<pre class="language-bash"><code class="language-bash">tailscale up --advertise-routes<span class="token operator">=</span><span class="token number">192.168</span>.1.0/24</code></pre>
|
|
<p>With the above command, I can access my Syncthing (and other jails too) wherever I am!</p>
|
|
<h2>Throughput</h2>
|
|
<p>Although the average latency in transmitting ICMP packets is unnoticeable, in the real world we mostly deal with TCP packets.</p>
|
|
<p>Syncthing transmits packets over TLS on top of TCP (which is great!) but in my needs it adds overhead as packets are already transmitted over secure protocol (Wireguard).</p>
|
|
<p>When I'm on my home network, the throughput is about 44 Mbits/s to my Syncthing jail since my laptop is connected over a WiFi network and on a different subnet. Ideally if on the same subnet (and over wired connection) my router and server can reach up to 900MiB/s.</p>
|
|
<p>What if I'm out of the house?</p>
|
|
<p>On a 50 Mbps network, using iperf3, I get around 6.49 MiB/s to my Syncthing jail and 8.56 MiB/s to direct host (depending on your network) which is… acceptable, kinda.
|
|
How about transferring 1.2GB files to my Syncthing jail over Tailscale?</p>
|
|
<p><img src="./CleanShot-2022-01-04-at-9.18.04@2x.png" alt=""></p>
|
|
<p>2.02 MiB/s is not bad enough, I guess?</p>
|
|
<h2>Conclusion</h2>
|
|
<p>Tailscale here is optional as Syncthing does the NAT traversal for you and also uses a secure protocol. Syncthing will do its best to establish a peer to peer connection and that's great!</p>
|
|
<p>However, with Tailscale I can access my "shared directory" via SAMBA on my other devices, anywhere. And also don't need any "Relay Server" only if my device can't talk peer-to-peer as Tailscale will do it for me :))</p>
|
|
<p>As closing, using both Tailscale and Syncthing is the best combination if you don't want to depend on a (cloud) storage providers.</p>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<footer class="c-footer u-clearfix">
|
|
<div class="c-footer__copyleft">
|
|
<p class="u-text-left">
|
|
© MMXXIII Rizaldy. Any and all opinions listed here are my own and not representative of my
|
|
employers; future, past and present.
|
|
</p>
|
|
</div>
|
|
<div class="c-footer__links">
|
|
<ul>
|
|
<li><a class="u-no-underline u-underline--hover" href="/">About</a></li>
|
|
<li><a class="u-no-underline u-underline--hover" href="/blog">Writings</a></li>
|
|
<li><a class="u-no-underline u-underline--hover" href="/colophon">Colophon</a></li>
|
|
<li>
|
|
<a class="u-no-underline u-underline--hover" href="https://github.com/faultables/rizaldy.today/commit/7263c0e"
|
|
>Source Code (7263c0e)</a
|
|
>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</footer>
|
|
|
|
</main>
|
|
|
|
<script
|
|
async
|
|
defer
|
|
data-website-id="868b4c29-d510-44fb-9404-50c19680d322"
|
|
data-do-not-track="true"
|
|
src="https://u.rizaldy.today/umami.js"
|
|
></script>
|
|
|
|
</body>
|
|
</html>
|