Skip to content

Commit fe0dd4c

Browse files
committed
Add service Tailscale Subnet Router Node
1 parent d57cd8b commit fe0dd4c

3 files changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#version=1.1
2+
#URL=https://github.com/tailscale-dev/ScaleTail
3+
#COMPOSE_PROJECT_NAME= # Optional: only use when running multiple deployments on the same infrastructure.
4+
5+
# Service Configuration
6+
SERVICE=tailscale-subnet-router-node
7+
IMAGE_URL=tailscale/tailscale
8+
9+
# Network Configuration
10+
SERVICEPORT= # Port to expose to local network. Uncomment the "ports:" section in compose.yaml to enable.
11+
DNS_SERVER=9.9.9.9
12+
13+
# Tailscale Configuration
14+
TS_AUTHKEY=
15+
16+
# Optional Service variables
17+
# PUID=1000
18+
19+
# Tailscale environment
20+
# Add comma separated list of subnet routes
21+
SUBNET_ROUTES=10.1.234.0/24 # See: https://tailscale.com/docs/features/subnet-routers
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Tailscale Subnet Router Node Configuration
2+
3+
This Docker Compose configuration sets up a Tailscale Subnet Router Node, allowing devices in your Tailscale network to route their traffic securely through this node to a local subnet. By configuring a Tailscale Router Node, you can extend your local network of device to tailscale connected clients, such as your home or office.
4+
5+
## Tailscale Subnet Router Node
6+
Subnet routers let you extend your Tailscale network (known as a tailnet) to include devices that don't or can't run the Tailscale client. They act as gateways between your tailnet and physical subnets, enabling secure access to legacy devices, entire networks, or services without installing Tailscale everywhere. This capability maintains Tailscale's security model while providing flexibility for complex network environments.
7+
8+
## Configuration Overview
9+
10+
In this setup, the `tailscale` service runs a Tailscale container configures it as a Subnet Router Node.
11+
12+
- **TS_AUTHKEY**: This environment variable in the .env file is where you insert your Tailscale authentication key.
13+
- **SUBNET_ROUTES**: This setting defined in .env file allows the user to set the desired route. More information can be found on the [Tailscale subnet router documents page.](https://tailscale.com/docs/features/subnet-routers)
14+
- **TS_EXTRA_ARGS**: The `--advertise-routes` flag is used to designate this container as a Subnet Router Node within your Tailscale network.
15+
- **Sysctls**: The system controls `net.ipv4.ip_forward` and `net.ipv6.conf.all.forwarding` are enabled to allow IP forwarding, which is necessary for routing traffic through the Exit Node.
16+
- **Network Mode**: The `bridge` network mode is used to create a virtual network interface for the container, enabling it to handle traffic routing.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
services:
2+
# Make sure you have updated/checked the .env file with the correct variables.
3+
# All the ${ xx } need to be defined there.
4+
# Tailscale Sidecar Configuration
5+
tailscale:
6+
image: tailscale/tailscale:latest # Image to be used
7+
container_name: tailscale-${SERVICE} # Name for local container management
8+
hostname: ${SERVICE} # Name used within your Tailscale environment
9+
environment:
10+
- TS_AUTHKEY=${TS_AUTHKEY}
11+
- TS_STATE_DIR=/var/lib/tailscale
12+
- TS_EXTRA_ARGS=--advertise-routes=${SUBNET_ROUTES}
13+
- TS_USERSPACE=false
14+
- TS_ENABLE_HEALTH_CHECK=true # Enable healthcheck endpoint: "/healthz"
15+
- TS_LOCAL_ADDR_PORT=127.0.0.1:41234 # The <addr>:<port> for the healthz endpoint
16+
#- TS_ACCEPT_DNS=true # Uncomment when using MagicDNS
17+
- TS_AUTH_ONCE=true
18+
volumes:
19+
- ./ts/state:/var/lib/tailscale # Tailscale requirement - you may need to change the path
20+
devices:
21+
- /dev/net/tun:/dev/net/tun # Network configuration for Tailscale to work
22+
dns:
23+
- ${DNS_SERVER}
24+
sysctls:
25+
net.ipv4.ip_forward: 1
26+
net.ipv6.conf.all.forwarding: 1
27+
cap_add:
28+
- net_admin # Tailscale requirement
29+
network_mode: bridge
30+
healthcheck:
31+
test: ["CMD", "wget", "--spider", "-q", "http://127.0.0.1:41234/healthz"] # Check Tailscale has a Tailnet IP and is operational
32+
interval: 1m # How often to perform the check
33+
timeout: 10s # Time to wait for the check to succeed
34+
retries: 3 # Number of retries before marking as unhealthy
35+
start_period: 10s # Time to wait before starting health checks
36+
restart: always

0 commit comments

Comments
 (0)