From 223fbd878ca648ba9622449d5219be0a49b5c1f7 Mon Sep 17 00:00:00 2001 From: Laszlo Magyar Date: Wed, 10 May 2023 10:21:46 +0200 Subject: [PATCH 1/2] Make userspace networking configurable --- tailscale/DOCS.md | 19 +++++++++++++++++++ tailscale/config.yaml | 1 + .../s6-overlay/s6-rc.d/post-tailscaled/run | 10 ++++++++++ .../etc/s6-overlay/s6-rc.d/tailscaled/run | 7 +++++++ tailscale/translations/en.yaml | 8 ++++++++ 5 files changed, 45 insertions(+) diff --git a/tailscale/DOCS.md b/tailscale/DOCS.md index 856bcb4b..acf64795 100644 --- a/tailscale/DOCS.md +++ b/tailscale/DOCS.md @@ -70,6 +70,7 @@ tags: - tag:example - tag:homeassistant taildrop: true +userspace_networking: true ``` ### Option: `accept_dns` @@ -186,6 +187,22 @@ the default (`https://controlplane.tailscale.com`). This is useful if you are running your own Tailscale control server, for example, a self-hosted [Headscale] instance. +### Option: `userspace_networking` + +The add-on uses [userspace networking mode][tailscale_info_userspace_networking] +to make your Home Assistant instance (and optionally the local subnets) +accessible within your tailnet. + +When not set, this option is enabled by default. + +If you need to access other clients on your tailnet from your Home Assistant +instance, disable userspace networking mode, that will create a `tailscale0` +network interface on your host. + +If you want to access other clients on your tailnet even from your local subnet, +execute Step 2 and 3 as described on [Site-to-site +networking][tailscale_info_site_to_site]. + ### Option: `proxy` When not set, this option is enabled by default. @@ -325,3 +342,5 @@ SOFTWARE. [tailscale_info_funnel]: https://tailscale.com/kb/1223/tailscale-funnel/ [tailscale_info_https]: https://tailscale.com/kb/1153/enabling-https/ [tailscale_info_key_expiry]: https://tailscale.com/kb/1028/key-expiry/ +[tailscale_info_site_to_site]: https://tailscale.com/kb/1214/site-to-site/ +[tailscale_info_userspace_networking]: https://tailscale.com/kb/1112/userspace-networking/ diff --git a/tailscale/config.yaml b/tailscale/config.yaml index 1cff18f2..e07d9d6a 100644 --- a/tailscale/config.yaml +++ b/tailscale/config.yaml @@ -36,3 +36,4 @@ schema: proxy: bool? tags: ["match(^tag:[a-zA-Z0-9]-?[a-zA-Z0-9]+$)?"] taildrop: bool? + userspace_networking: bool? diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/post-tailscaled/run b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/post-tailscaled/run index 399284a8..85da8e64 100755 --- a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/post-tailscaled/run +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/post-tailscaled/run @@ -122,3 +122,13 @@ if keyexpiry=$(/opt/tailscale status --self=true --peers=false --json | jq -rce fi bashio::log.info "Tailscale is running" + +# Warn about userspace networking +if ! bashio::config.has_value "userspace_networking" || \ + bashio::config.true "userspace_networking"; +then + bashio::log.notice "The add-on uses userspace networking mode." + bashio::log.notice "If you need to access other clients on your tailnet from your Home Assistant instance," + bashio::log.notice "disable userspace networking mode, that will create a \"tailscale0\" network interface on your host." + bashio::log.notice "Please check your configuration based on the add-on's Documentation under \"Option: userspace_networking\"" +fi diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/tailscaled/run b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/tailscaled/run index 7a9382cf..558fdb7b 100755 --- a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/tailscaled/run +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/tailscaled/run @@ -16,6 +16,13 @@ if ! bashio::debug ; then options+=(--no-logs-no-support) fi +# Use userspace networking by default when not set, or when explicitly enabled +if ! bashio::config.has_value "userspace_networking" || \ + bashio::config.true "userspace_networking"; +then + options+=(--tun=userspace-networking) +fi + # Run Tailscale if bashio::debug ; then exec /opt/tailscaled "${options[@]}" diff --git a/tailscale/translations/en.yaml b/tailscale/translations/en.yaml index ab840687..ada4b1d0 100644 --- a/tailscale/translations/en.yaml +++ b/tailscale/translations/en.yaml @@ -54,3 +54,11 @@ configuration: This option allows you to enable Taildrop, a file sharing service that allows you to share files with other Tailscale nodes. When not set, this option is enabled by default. + userspace_networking: + name: Userspace networking mode + description: >- + This option allows you to enable userspace networking mode. + If you need to access other clients on your Tailnet from your Home + Assistant instance, disable userspace networking mode, that will create a + `tailscale0` network interface on your host. + When not set, this option is enabled by default. From 1d90a38af08d43ebd33b6ab6fb84a976e1ec72ed Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 15 Oct 2023 21:15:42 +0200 Subject: [PATCH 2/2] Doc tweaks --- tailscale/DOCS.md | 4 ++-- tailscale/translations/en.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tailscale/DOCS.md b/tailscale/DOCS.md index acf64795..317e45c7 100644 --- a/tailscale/DOCS.md +++ b/tailscale/DOCS.md @@ -196,11 +196,11 @@ accessible within your tailnet. When not set, this option is enabled by default. If you need to access other clients on your tailnet from your Home Assistant -instance, disable userspace networking mode, that will create a `tailscale0` +instance, disable userspace networking mode, which will create a `tailscale0` network interface on your host. If you want to access other clients on your tailnet even from your local subnet, -execute Step 2 and 3 as described on [Site-to-site +execute steps 2 and 3 as described on [Site-to-site networking][tailscale_info_site_to_site]. ### Option: `proxy` diff --git a/tailscale/translations/en.yaml b/tailscale/translations/en.yaml index ada4b1d0..daf00eed 100644 --- a/tailscale/translations/en.yaml +++ b/tailscale/translations/en.yaml @@ -59,6 +59,6 @@ configuration: description: >- This option allows you to enable userspace networking mode. If you need to access other clients on your Tailnet from your Home - Assistant instance, disable userspace networking mode, that will create a + Assistant instance, disable userspace networking mode, which will create a `tailscale0` network interface on your host. When not set, this option is enabled by default.