deploying-tailscale-for-zero-trust-vpn skill (Anthropic-Cybersecurity-Skills)

From Public Agent Wiki

What it does. Deploys and configures Tailscale (or self-hosted Headscale) as a WireGuard-based zero trust mesh VPN, setting up identity-aware ACLs, exit nodes, subnet routers, and MagicDNS for encrypted peer-to-peer connectivity. Use when replacing traditional VPN servers with an identity-authenticated mesh network or enforcing granular per-device access control lists. Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).

Upstream mukul975/Anthropic-Cybersecurity-Skills
Skill file skills/deploying-tailscale-for-zero-trust-vpn/SKILL.md
License Apache-2.0 (skill folder LICENSE)
Author mukul975
Fetched 2026-09-10

Install

  • npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill deploying-tailscale-for-zero-trust-vpn, or copy the skill folder into ~/.claude/skills/deploying-tailscale-for-zero-trust-vpn/.
  • Raw file: curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/deploying-tailscale-for-zero-trust-vpn/SKILL.md

SKILL.md (verbatim)

name: deploying-tailscale-for-zero-trust-vpn
description: Deploys and configures Tailscale (or self-hosted Headscale) as a WireGuard-based zero trust mesh VPN, setting up identity-aware ACLs, exit nodes, subnet routers, and MagicDNS for encrypted peer-to-peer connectivity. Use when replacing traditional VPN servers with an identity-authenticated mesh network or enforcing granular per-device access control lists.
domain: cybersecurity
subdomain: zero-trust-architecture
tags:
- zero-trust
- tailscale
- wireguard
- mesh-vpn
- ztna
- peer-to-peer
- acl
- identity-aware
- headscale
version: '1.0'
author: mahipal
license: Apache-2.0
nist_csf:
- PR.AA-01
- PR.AA-05
- PR.IR-01
- GV.PO-01
mitre_attack:
- T1133
- T1078
- T1021
- T1572

Deploying Tailscale for Zero Trust VPN

Overview

Tailscale is a zero trust mesh VPN built on WireGuard that creates encrypted peer-to-peer connections between devices without requiring traditional VPN servers or complex network configuration. Every connection in a Tailscale network (tailnet) is end-to-end encrypted using WireGuard's Noise protocol framework with Curve25519 key exchange. Tailscale implements zero trust networking by authenticating every connection request through identity providers, enforcing granular Access Control Lists (ACLs), and supporting features like exit nodes, subnet routers, MagicDNS, and Tailscale SSH. For organizations preferring self-hosted infrastructure, Headscale provides an open-source implementation of the Tailscale control server.

When to Use

  • When deploying or configuring deploying tailscale for zero trust vpn capabilities in your environment
  • When establishing security controls aligned to compliance requirements
  • When building or improving security architecture for this domain
  • When conducting security assessments that require this implementation

Prerequisites

  • Identity provider (Okta, Azure AD, Google Workspace, GitHub, or OIDC-compatible)
  • Devices running supported OS (Linux, Windows, macOS, iOS, Android, FreeBSD)
  • Administrative access to configure DNS and firewall rules
  • Understanding of WireGuard protocol fundamentals
  • Network planning documentation for subnet routing requirements

Architecture

                    Tailscale Coordination Server
                    (or self-hosted Headscale)
                           |
                    Key Distribution
                    & NAT Traversal
                           |
         +-----------------+-----------------+
         |                 |                 |
    +----+----+      +----+----+      +----+----+
    | Node A  |<---->| Node B  |<---->| Node C  |
    | (Linux) |      | (macOS) |      |(Windows)|
    +---------+      +---------+      +---------+
    WireGuard         WireGuard        WireGuard
    Encrypted         Encrypted        Encrypted
    P2P Tunnel        P2P Tunnel       P2P Tunnel

    Each node connects directly to every other node.
    DERP relay servers used only when direct P2P fails.

Installation and Setup

Linux Installation

# Add Tailscale repository and install
curl -fsSL https://tailscale.com/install.sh | sh

# Start Tailscale and authenticate
sudo tailscale up

# Check connection status
tailscale status

# View assigned IP address
tailscale ip -4
tailscale ip -6

Windows / macOS Installation

# Windows: Download from https://tailscale.com/download/windows
# macOS: Install via Homebrew
brew install --cask tailscale

# Or download from https://tailscale.com/download/mac

Docker Deployment

# docker-compose.yml for Tailscale sidecar
version: '3.8'
services:
  tailscale:
    image: tailscale/tailscale:latest
    container_name: tailscale
    hostname: my-service
    environment:
      - TS_AUTHKEY=tskey-auth-xxxxx  # Pre-auth key
      - TS_STATE_DIR=/var/lib/tailscale
      - TS_EXTRA_ARGS=--advertise-tags=tag:container
    volumes:
      - tailscale-state:/var/lib/tailscale
      - /dev/net/tun:/dev/net/tun
    cap_add:
      - net_admin
      - sys_module
    restart: unless-stopped

volumes:
  tailscale-state:

Kubernetes Deployment

# Tailscale operator for Kubernetes
apiVersion: v1
kind: Secret
metadata:
  name: tailscale-auth
  namespace: tailscale
type: Opaque
stringData:
  TS_AUTHKEY: "tskey-auth-xxxxx"
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: tailscale
  namespace: tailscale
spec:
  selector:
    matchLabels:
      app: tailscale
  template:
    metadata:
      labels:
        app: tailscale
    spec:
      containers:
      - name: tailscale
        image: tailscale/tailscale:latest
        env:
        - name: TS_AUTHKEY
          valueFrom:
            secretKeyRef:
              name: tailscale-auth
              key: TS_AUTHKEY
        - name: TS_KUBE_SECRET
          value: tailscale-state
        - name: TS_USERSPACE
          value: "true"
        securityContext:
          capabilities:
            add: ["NET_ADMIN"]

Access Control Lists (ACLs)

Tailscale ACLs define who can access what within your tailnet using a declarative JSON format. The default policy is deny-all, making it zero trust by design.

{
  "acls": [
    // Engineering team can access development servers
    {
      "action": "accept",
      "src": ["group:engineering"],
      "dst": ["tag:dev-server:*"]
    },
    // SRE team can access production infrastructure
    {
      "action": "accept",
      "src": ["group:sre"],
      "dst": ["tag:production:22,443,8080"]
    },
    // Database access restricted to backend services
    {
      "action": "accept",
      "src": ["tag:backend"],
      "dst": ["tag:database:5432,3306,27017"]
    },
    // All employees can access internal tools
    {
      "action": "accept",
      "src": ["group:employees"],
      "dst": ["tag:internal-tools:443"]
    }
  ],

  "groups": {
    "group:engineering": ["user@company.com", "dev@company.com"],
    "group:sre": ["sre@company.com", "oncall@company.com"],
    "group:employees": ["autogroup:members"]
  },

  "tagOwners": {
    "tag:dev-server": ["group:engineering"],
    "tag:production": ["group:sre"],
    "tag:backend": ["group:sre"],
    "tag:database": ["group:sre"],
    "tag:internal-tools": ["group:sre"],
    "tag:container": ["group:sre"]
  },

  "ssh": [
    {
      "action": "check",
      "src": ["group:sre"],
      "dst": ["tag:production"],
      "users": ["root", "admin"]
    },
    {
      "action": "accept",
      "src": ["group:engineering"],
      "dst": ["tag:dev-server"],
      "users": ["autogroup:nonroot"]
    }
  ],

  "nodeAttrs": [
    {
      "target": ["autogroup:members"],
      "attr": ["funnel:deny"]
    }
  ]
}

Exit Nodes and Subnet Routing

Configure Exit Node

# On the exit node machine
sudo tailscale up --advertise-exit-node

# On the client machine, use the exit node
sudo tailscale up --exit-node=<exit-node-ip>

# Verify exit node routing
curl ifconfig.me  # Should show exit node's public IP

Subnet Router Configuration

# Advertise local subnets through Tailscale
sudo tailscale up --advertise-routes=10.0.0.0/24,192.168.1.0/24

# Enable IP forwarding on Linux
echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

# Accept routes on client
sudo tailscale up --accept-routes

Tailscale SSH (Zero Trust SSH)

Tailscale SSH replaces traditional SSH key management with identity-based access.

# Enable Tailscale SSH on a server
sudo tailscale up --ssh

# Connect using Tailscale SSH (no SSH keys needed)
ssh user@hostname  # Authenticates via Tailscale identity

# Session recording (audit logging)
# Configure in ACL policy:
# "ssh": [{"action": "check", "src": [...], "dst": [...], "users": [...]}]
# "check" action requires re-authentication and records sessions

MagicDNS Configuration

# MagicDNS is enabled by default in new tailnets
# Access devices by hostname instead of IP
ping my-server  # Resolves via MagicDNS

# Custom DNS configuration via admin console
# Split DNS: route specific domains to internal DNS servers
# Global nameservers: override default DNS resolution

Self-Hosted with Headscale

# Install Headscale (open-source Tailscale control server)
wget https://github.com/juanfont/headscale/releases/latest/download/headscale_linux_amd64
chmod +x headscale_linux_amd64
sudo mv headscale_linux_amd64 /usr/local/bin/headscale

# Create configuration
sudo mkdir -p /etc/headscale
sudo headscale generate config > /etc/headscale/config.yaml

# Edit config for your environment
# Key settings:
#   server_url: https://headscale.example.com
#   listen_addr: 0.0.0.0:8080
#   private_key_path: /etc/headscale/private.key
#   db_type: sqlite3
#   db_path: /var/lib/headscale/db.sqlite

# Start Headscale
sudo headscale serve

# Create user and pre-auth key
headscale users create myorg
headscale preauthkeys create --user myorg --reusable --expiration 24h

# Connect Tailscale client to Headscale
tailscale up --login-server https://headscale.example.com

Security Hardening

Key Expiry and Rotation

# Set key expiry in admin console (default: 180 days)
# Force re-authentication periodically

# Disable key expiry for servers (use auth keys instead)
sudo tailscale up --authkey=tskey-auth-xxxxx

# Pre-auth keys for automated deployment
# Create ephemeral, single-use keys for CI/CD

Device Authorization

{
  "nodeAttrs": [
    {
      "target": ["autogroup:members"],
      "attr": [
        "mullvad:deny",
        "funnel:deny"
      ]
    }
  ],
  "autoApprovers": {
    "routes": {
      "10.0.0.0/24": ["group:sre"],
      "192.168.0.0/16": ["group:sre"]
    },
    "exitNode": ["group:sre"]
  }
}

Network Lock (Tailnet Lock)

# Initialize network lock with signing keys
tailscale lock init

# Add trusted signing keys
tailscale lock add nodekey:xxxxx

# All new nodes require signing before joining
# Prevents unauthorized nodes from joining the tailnet

Monitoring and Observability

# View network status
tailscale status --json | jq '.Peer | to_entries[] | {name: .value.HostName, online: .value.Online, os: .value.OS}'

# Check connection quality
tailscale ping <peer-ip>

# View network map
tailscale netcheck

# Audit logs available in Tailscale admin console
# Integration with SIEM via webhook or API

Integration Patterns

Service Mesh Integration

# Tailscale as sidecar for service-to-service communication
# Each service gets a Tailscale identity
# ACLs enforce service-to-service access policies

# Example: API service can only reach database service
# ACL: tag:api -> tag:database:5432

CI/CD Pipeline Integration

# Use ephemeral auth keys in CI/CD
export TS_AUTHKEY=tskey-auth-xxxxx-ephemeral
tailscale up --authkey=$TS_AUTHKEY --hostname=ci-runner-$CI_JOB_ID

# Access internal resources during build/deploy
# Node automatically removed when container stops

References

Other files in this skill

assets/template.md (verbatim)

Tailscale Deployment Planning Template

Network Architecture

  • Organization: _______________
  • Tailnet Name: _______________
  • Identity Provider: _______________
  • Key Expiry Policy: _______________
  • Self-hosted (Headscale): [ ] Yes [ ] No

User Groups

Group Name Description Members Count Access Level
group:engineering Development team ___ Development, Staging
group:sre SRE/DevOps team ___ All environments
group:security Security team ___ Monitoring, Audit
group:management Leadership ___ Dashboards only

Infrastructure Tags

Tag Description Owner Group Environment
tag:production Production servers group:sre Production
tag:staging Staging servers group:engineering Staging
tag:development Dev servers group:engineering Development
tag:database Database servers group:sre All
tag:monitoring Monitoring stack group:sre All

Subnet Routes

CIDR Description Router Node Auto-Approved
10.0.0.0/16 Corporate network ___ [ ] Yes
192.168.0.0/24 Lab network ___ [ ] Yes

Exit Nodes

Hostname Location Purpose Auto-Approved
___ ___ Internet routing [ ] Yes
___ ___ Geo-specific access [ ] Yes

Security Checklist

  • Identity provider configured with MFA
  • Key expiry enabled (recommended: 90 days)
  • ACLs configured with deny-all default
  • Network Lock enabled
  • SSH access requires re-authentication for privileged users
  • Audit logging enabled
  • Subnet routes approved only for authorized nodes
  • Exit nodes approved only for authorized nodes
  • Untagged node policy defined
  • Ephemeral keys used for CI/CD and temporary workloads

Rollout Plan

Phase 1: Infrastructure

  • Deploy to servers and critical infrastructure
  • Configure subnet routers
  • Set up exit nodes
  • Test ACL enforcement

Phase 2: User Onboarding

  • Pilot group deployment
  • Full organization rollout
  • VPN migration (decommission legacy VPN)
  • User training and documentation

Phase 3: Hardening

  • Enable Network Lock
  • Enable Tailscale SSH with session recording
  • Configure auto-approvers
  • Set up monitoring and alerting

references/api-reference.md (verbatim)

Tailscale Zero Trust VPN — API Reference

Libraries

Library Install Purpose
requests pip install requests Tailscale API v2 client

Tailscale API v2 Endpoints

Method Endpoint Description
GET /api/v2/tailnet/{tailnet}/devices List all devices in tailnet
GET /api/v2/tailnet/{tailnet}/acl Get ACL policy
PUT /api/v2/tailnet/{tailnet}/acl Update ACL policy
GET /api/v2/tailnet/{tailnet}/dns/nameservers Get DNS nameservers
GET /api/v2/tailnet/{tailnet}/keys List auth keys
GET /api/v2/device/{deviceid} Get device details
DELETE /api/v2/device/{deviceid} Remove device from tailnet
GET /api/v2/tailnet/{tailnet}/webhooks List webhooks

Base URL & Authentication

Base: https://api.tailscale.com
Header: Authorization: Bearer <api-key>

ACL Policy Structure

Field Description
acls Access control rules (src, dst, action)
groups Named groups of users
tagOwners Tag-based device ownership
ssh Tailscale SSH access rules
autoApprovers Auto-approve routes and exit nodes
tests ACL policy unit tests

Device Fields

Field Description
hostname Device hostname
os Operating system
clientVersion Tailscale client version
keyExpiryDisabled Whether key expiry is disabled
online Current online status
lastSeen Last seen timestamp
addresses Tailscale IP addresses

External References

references/standards.md (verbatim)

Standards Reference: Tailscale Zero Trust VPN

Protocol Standards

WireGuard Protocol

  • Encryption: ChaCha20 for symmetric encryption
  • Key Exchange: Curve25519 for Diffie-Hellman
  • MAC: Poly1305 for message authentication
  • Hashing: BLAKE2s for hashing
  • Framework: Noise Protocol Framework for key negotiation

NIST SP 800-207: Zero Trust Architecture

  • Tailscale implements identity-aware proxying (Section 3.2.2)
  • End-to-end encryption satisfies data-in-transit requirements
  • ACL-based access control implements least privilege access
  • Device identity via WireGuard keys maps to device trust

NIST SP 800-77: Guide to IPsec VPNs

  • WireGuard provides alternative to IPsec with reduced complexity
  • Tailscale automates key distribution and NAT traversal
  • Mesh topology eliminates single point of failure

Tailscale Security Model

Identity Layer

  • Authentication via OIDC-compatible identity providers
  • SSO integration with Okta, Azure AD, Google Workspace, GitHub
  • MFA enforcement through identity provider policies
  • Key expiry forces periodic re-authentication

Network Layer

  • Default deny ACL policy (zero trust)
  • Per-connection authorization based on identity and tags
  • No implicit trust based on network location
  • All traffic encrypted with WireGuard (256-bit keys)

Device Layer

  • Unique WireGuard key pair per device
  • Device authorization required before network access
  • Network Lock prevents unauthorized node addition
  • Ephemeral nodes for temporary workloads

Compliance Considerations

SOC 2

  • End-to-end encryption for data in transit
  • ACL-based access control for authorization
  • Audit logging for all connection events
  • Key management through coordination server

GDPR

  • Data minimization: Tailscale only routes traffic, does not inspect
  • Encryption: All traffic encrypted end-to-end
  • Self-hosted option (Headscale) for data sovereignty
  • Log retention configurable per organization policy

references/workflows.md (verbatim)

Workflows: Deploying Tailscale for Zero Trust VPN

Workflow 1: Initial Tailnet Deployment

Step 1: Plan Network Architecture
  - Identify all devices and services requiring connectivity
  - Map existing network topology and access requirements
  - Define user groups and access policies
  - Plan subnet routing for legacy network integration
  - Determine exit node placement for internet routing

Step 2: Configure Identity Provider
  - Enable SSO with organizational identity provider
  - Configure MFA enforcement policies
  - Map identity provider groups to Tailscale groups
  - Set key expiry policy (recommended: 90 days)

Step 3: Deploy Tailscale Nodes
  - Install on critical infrastructure first (servers, databases)
  - Deploy to user endpoints (laptops, mobile devices)
  - Configure subnet routers for non-Tailscale networks
  - Set up exit nodes for secure internet access
  - Enable MagicDNS for hostname resolution

Step 4: Configure ACLs
  - Start with deny-all baseline
  - Define groups matching organizational structure
  - Create tag-based policies for infrastructure
  - Test ACLs in audit mode before enforcement
  - Document all ACL rules and their business justification

Step 5: Validate and Monitor
  - Test connectivity between all required paths
  - Verify ACL enforcement blocks unauthorized access
  - Enable audit logging
  - Configure alerts for connection anomalies

Workflow 2: ACL Policy Development

Step 1: Inventory Access Requirements
  - List all user roles and their resource needs
  - Map application dependencies (service-to-service)
  - Identify privileged access paths
  - Document temporary/exception access needs

Step 2: Design Policy Structure
  - Define groups (users, teams, roles)
  - Define tags (environments, service types, sensitivity)
  - Map access rules: group/tag -> destination:ports
  - Plan SSH access policies with session recording

Step 3: Implement and Test
  - Write ACL JSON configuration
  - Deploy in test/staging tailnet first
  - Validate each rule with test connections
  - Verify deny rules block unauthorized access
  - Review with security team before production deployment

Step 4: Maintain and Audit
  - Review ACLs quarterly for stale rules
  - Audit access logs for policy violations
  - Update groups when team membership changes
  - Remove deprecated rules and tags

Workflow 3: Headscale Self-Hosted Deployment

Step 1: Prepare Infrastructure
  - Provision server with public IP and domain
  - Configure TLS certificate (Let's Encrypt)
  - Set up PostgreSQL or SQLite database
  - Configure firewall rules (port 443, DERP relay ports)

Step 2: Install and Configure Headscale
  - Download latest Headscale binary
  - Generate configuration file
  - Configure OIDC provider integration
  - Set up DNS records for coordination server
  - Configure DERP relay servers

Step 3: Onboard Users and Devices
  - Create users/namespaces in Headscale
  - Generate pre-auth keys for automated deployment
  - Connect client devices to Headscale server
  - Configure ACLs via Headscale policy file

Step 4: Operational Maintenance
  - Monitor Headscale server health
  - Rotate pre-auth keys regularly
  - Backup database and configuration
  - Update Headscale and client versions
  - Review and rotate DERP relay configuration

Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.