Home Assistant Community Add-on: Tinc VPN Client

Hello everyone,

I would like to announce my first Home Assistant Community Add-on:

Tinc VPN Client

Please let me know if you have any questions or suggestions (PRs are welcome).

About

tinc is a Virtual Private Network (VPN) daemon that uses tunneling and encryption to create a secure private network between hosts on the Internet.

Install Instructions

To use Tinc VPN Client Add-on, you should set up tinc server first.

The second step is to generate tinc keys, eg. tincd -n tinc0 -K4096

The third step is to convert keys (public and private) to base64 format, eg. cat /etc/tinc/rsa_key.priv | base64 -w 0

The fourth step is to install Tinc VPN Client Add-on and configure it before starting.

See the DOCS.md for further details.

Could you please elaborate on a usecase for this VPN client?

Great, thanks for writing it!!

@Viking , itā€™s a bit similar to the Zerotier addon. Itā€™s also a peer 2 peer VPN. Itā€™s totally self-hosted though unlike Zerotier which is why people use it over zerotier.

I have used Zerotier and tailscale and find that Zerotier works alot better for throughput.
How does tinc do in that regard?
Ever compared?

Well, I have OpenVPN running on a Linux NAS and it works well. Would adding Tinc bring along any new features?

@Viking OpenVPN is a point to point VPN. All your endpoints connect to a single server.

Zerotier, Tailscale, and Tinc (and also Nebula for that matter) are peer to peer VPNs. Itā€™s also quite similar to hamachi that is used a lot for gaming. That means that while there is a central coordination instance, peers can connect directly if a more direct path is available. So if your laptops are on the same wifi they will simply build a direct (encrypted) connection but if you bring one to the coffeeshop across the road they will keep communicating but through a ā€œserverā€ (if both networks are behind NAT)

I use it mainly to have an ā€œinternalā€ IP range on all my devices thatā€™s available wherever I am with my devices. Both on mobile, desktops, devices (home assistant etc). Until now I didnā€™t find a tinc client for home assistant so I was using a standard Linux install with the HASS docker on top instead of home assistant os. Because home assistant os is so locked down I could not install it on there and I really need it :slight_smile: Itā€™s great that mdzidic made this addon, I will try it to see if it suffices. Because Iā€™m thinking of moving to the OS and this was a blocking point.

In terms of performance @danbutter I donā€™t really know. Iā€™ve only ever used tinc. I donā€™t like the centralised approach of zerotier or tailscale. I know there is a self-hosted option for tailscale in the form of headscale, but I already have tinc running and now that thereā€™s a good Android client I just didnā€™t see any need to change.

Tinc is the oldest of all these options (Iā€™ve used it for decades!) so itā€™s probably not quite as advanced in terms of hole punching NATs etc. Itā€™s certainly not as glossy as tailscale. But it works fine for me and itā€™s fully self hosted and thereā€™s not a commercial entity behind it like there is with tailscale, zerotier and nebula (which is from slack). So I donā€™t have to worry about them trying to push subscription schemes and undermining self-hosted options. So Iā€™m just not bothered about changing it.

I must have misunderstood things. In my book, a VPN is a HUB-Spoke network where all clients log onto a sentral VPN server using classical authentication, typically username/password. While peer-to-peer communication does not require a server once the communication and authorization has been done. Hence the name Peer-to-Peer VPN becomes a contradiction in terms? It must be either or, not both, right. Horses do not come with wheels.
So what is this thing called Tinc? Is it just another VPN client? Or is it a peer client? If so where is the comm setup and authentication handled? Can I install a self-managed version, invisible to Home Assistant?

Hello there,

If you have running tincd (tinc daemon/server) you can use this add-on as HA tinc client. As @GP123 already mentioned itā€™s a free and self-hosted alternative to all currently available cloud services for peer-to-peer networking.

Of course, tinc is less popular than OpenVPN, but tinc focuses more on performance and security over speed.

Before Nabu Casa and cloudflared tunnel add-on, I have been using tinc to expose my HA instance in combination with balance and VPS (static public IP).

So Tincd is the server. Can that be run in a docker container on a Linux platform anywhere? I assume this server has to be reachable from the internet in order to be able to provide its services, right?
And then this thread talks about a Tinc client tailored specifically for HA, right? Or is it just a general purpose client that will expose any web service defined by an IP:Port or DNS name?

Hello,

You can find some tinc usage examples at tinc-vpn.org/examples/

Of course, you can dockerize it but donā€™t forget to allow docker privilege ā€œNET_ADMINā€ on that container. You can follow the source code on my GitHub link and replicate it for your Linux server.

True, this add-on is tailored for HA to act as a ā€œclient 2 serverā€ and you can do whatever you want on your server side once you have your HA instance connected to tinc private network (it will not expose your HA instance to the world by default).

Itā€™s a little bit different than you explain @Viking, what you would normally do is to install tinc on every device you have so they can communicate together. Itā€™s a mesh VPN, not a VPN with a single central point.

Every client is also a ā€œserverā€, but normally you would have a central server on a VPS exposed to the internet that is always reachable. So in that way you kinda have a central point, but if the clients can ā€˜seeā€™ each other itā€™s more for coordination than actually handling all your traffic.

Normally on a linux server I wouldnā€™t bother with docker for it because itā€™s such a tiny daemon (115kb literally). Docker would incur a lot of overhead. Of course on home assistant OS itā€™s the only option.

And yeah I prefer it over the Nabu Casa option because Iā€™m only dependent on myself for security then, and Home Assistant is not the only self-hosted service I expose this way (by far!)

1 Like

I just wonder why itā€™s named tinc-vpn when it is clearly not a virtual private network but a peering network? I find that name confusing and incorrect.

It is a virtual private network. Just a different type than the traditional point to point type. Itā€™s simply an evolution of VPN, with the added optimisation that clients can communicate directly when they have a different path between them (but fall back to the traditional method when they donā€™t). This is better than a traditional VPN because it improves throughput and latency where possible. But it still provides the exact same which is a secure tunnel between your devices. You can also include a whole subnet between a tinc node like you would with a traditional VPN, itā€™s just not normally done because you lose the routing optimisation (and add a dependency on that tinc node for everything!). Itā€™s really nice to be able to still reach your other devices when your server is down.

See the most popular option right now in the same niche: Tailscale ā€œBest VPN Service for secure networksā€. Theyā€™re all marketing themselves as VPN, though some try to give a different spin on it to make it sound like theyā€™re more special (like Zerotier with their ā€œGlobal Area WANā€).

PS: I see Tailscale is also listed on the Home Assistant store as a VPN. And it does the exact same thing as tinc :slight_smile:

1 Like

I couldnā€™t remember why I have never tried tinc before as it is even an addon for pfsense and running directly on the router would be best case scenario. I looked again and found out why.

Your mileage may vary depending on your ISP, but the thing I see as a non starter for tinc is that it wonā€™t work for those behind cgnat.
Quote from their siteā€¦
ā€œAs long as one node in the VPN allows incoming connections on a public IP addressā€
I know this is less common, but it happens.
Whereas tailscale and Zerotier will work because of their coordination servers. I understand the trust you have to put into these companies, but if you have cgnat and you donā€™t want to trust a company like zerotier or others you have to pay someone to do something outside your network even if that something is running a vps with tinc on it.
So all these donā€™t do the exact same thing even if your internet provider is setup such that you get the same result.

Either way, good job on the addon. I bet plenty will get use from it.

Hey @danbutter ,

As we already mentioned before, it can be used as simple VPN service (server/client), as many of us already have VPS server in the public cloud (or if not, you can buy one for a few bucks per month) with public IP assigned to that VPS server, we use that VPS as ā€œcentralā€ tinc server or coordinator/lighthouse server if you like, your device behind CGNAT will be able to connect to that ā€œcentralā€ tinc server.

CGNAT will only block the mesh feature of the tinc service where every client is also the server.

Gotcha.
I was just saying it differs from tailscale and zerotier as you donā€™t need to have that vps in the cloud to use them in the case of having cgnat from your isp.
If youā€™re gonna pay for something just to get remote access to home assistant you might as well use naba casa cloud and support development.

Gotcha.
I was just saying it differs from tailscale and zerotier as you donā€™t need to have that vps in the cloud to use them in the case of having cgnat from your isp.

Tailscale and Zerotier host that ā€œVPSā€ for you, thatā€™s why. You still need that central point. Itā€™s just part of the (free) service they provide. I donā€™t like giving the keys of my VPN to a third party, so theyā€™re non-starters for me (though tailscale can be self-hosted using headscale, technically).

If youā€™re gonna pay for something just to get remote access to home assistant you might as well use naba casa cloud and support development.

True but Home Assistant isnā€™t the only thing I use my VPN for. I have a ton of stuff behind it. As an example, I have a matrix server running at home interfacing to WhatsApp, Signal, Telegram, Discord etc. And tons of other servers at home for other things. All that also goes over tinc when Iā€™m away. I have a lot more control over my security this way as I donā€™t rely on a third party to configure things for me (perhaps incorrectly).

I run other things on my VPSā€™es too, like IRC bouncers and other things. I donā€™t need them just for this.

I know the Nabu Casa service but itā€™s not what I want, at least for this. Perhaps I will get it some time for the text to speech.

@mdzidic

CGNAT will only block the mesh feature of the tinc service where every client is also the server.

Indeed, and if the endpoint it is trying to connect to is not behind (CG)NAT itself can still work! Because the one behind NAT can connect to the other one. With IPv6 this is more common.

Some other VPNs like Tailscale and Nebula can also do ā€œNAT Hole-Punchingā€ by sending fake packets to simulate an existing NAT connection. However I donā€™t think Tinc does this, as far as I have seen. Itā€™s not a problem bothersome enough for me to change over though. I like tinc.

1 Like

Tinc v1.1 supports hole punching when you have node which is not behind NAT (eg. your VPS server), personally I have never tested it.

Ref. How connections work (tinc Manual)

1 Like

Oh I didnā€™t know that. I do use that version. I didnā€™t see it working but I will do some more detailed analysis.

Sometimes I transfer large amounts (off-site backup) and it would be great if it can go end to end. Thanks!