Configure Tailscale mesh VPN with subnet routing and ACL policies for secure network access

Intermediate 25 min Apr 03, 2026 19 views
Ubuntu 24.04 Ubuntu 22.04 Debian 12 AlmaLinux 9 Rocky Linux 9 Fedora 41

Set up a zero-trust mesh VPN network with Tailscale that includes subnet routing for local network access, granular ACL policies for security, and exit nodes for secure internet access.

Prerequisites

  • Root or sudo access
  • Internet connectivity
  • Tailscale account (free tier available)
  • Local network subnet knowledge

What this solves

Tailscale creates a secure mesh VPN network that connects devices across the internet without complex firewall configurations or port forwarding. This tutorial shows you how to implement subnet routing to access remote local networks, configure ACL policies for zero-trust security, and set up exit nodes for secure internet browsing through your network.

Step-by-step configuration

Update system packages

Start by updating your package manager to ensure you get the latest versions.

sudo apt update && sudo apt upgrade -y
sudo dnf update -y

Install Tailscale client

Install the official Tailscale package from their repository to ensure you get automatic updates and the latest security patches.

curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/$(lsb_release -cs).noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/$(lsb_release -cs).tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list
sudo apt update
sudo apt install -y tailscale
sudo dnf config-manager --add-repo https://pkgs.tailscale.com/stable/rhel/9/tailscale.repo
sudo dnf install -y tailscale

Enable and start Tailscale service

Enable the Tailscale daemon to start automatically on boot and verify it's running properly.

sudo systemctl enable --now tailscaled
sudo systemctl status tailscaled

Authenticate with Tailscale

Connect this device to your Tailscale network by authenticating through the web interface. This command generates a unique authentication URL.

sudo tailscale up

Open the provided URL in your web browser and follow the authentication process. If you don't have a Tailscale account, create one during this step.

Configure subnet routing

Enable this device to route traffic for your local subnet, allowing other Tailscale devices to access local network resources like printers, NAS devices, or internal services.

sudo tailscale up --advertise-routes=192.168.1.0/24

Replace 192.168.1.0/24 with your actual local network subnet. For multiple subnets, use comma separation like --advertise-routes=192.168.1.0/24,10.0.0.0/8.

Note: Subnet routes must be approved in the Tailscale admin console before they become active.

Enable IP forwarding

Configure the kernel to forward packets between network interfaces, which is required for subnet routing to function properly.

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

Configure exit node capability

Enable this device to act as an exit node, allowing other Tailscale devices to route all their internet traffic through this connection for enhanced privacy or to access geo-restricted content.

sudo tailscale up --advertise-exit-node
Warning: Exit nodes handle all internet traffic for connected devices. Ensure this server has adequate bandwidth and consider the legal implications in your jurisdiction.

Create ACL policy file

Access your Tailscale admin console at https://login.tailscale.com/admin/acls to configure access control policies. Replace the default policy with this zero-trust configuration.

{
  "tagOwners": {
    "tag:server": ["autogroup:admin"],
    "tag:client": ["autogroup:admin"],
    "tag:printer": ["autogroup:admin"]
  },
  "groups": {
    "group:developers": ["user1@example.com", "user2@example.com"],
    "group:admins": ["admin@example.com"]
  },
  "acls": [
    {
      "action": "accept",
      "src": ["group:admins"],
      "dst": [":"]
    },
    {
      "action": "accept",
      "src": ["group:developers"],
      "dst": ["tag:server:22,80,443,8080"]
    },
    {
      "action": "accept",
      "src": ["tag:client"],
      "dst": ["tag:server:80,443"]
    },
    {
      "action": "accept",
      "src": ["autogroup:members"],
      "dst": ["tag:printer:631,9100"]
    }
  ],
  "ssh": [
    {
      "action": "accept",
      "src": ["group:admins"],
      "dst": ["tag:server"],
      "users": ["root", "autogroup:nonroot"]
    }
  ]
}

Apply device tags

Tag devices in your Tailscale admin console to apply the ACL policies. Navigate to the Machines tab and edit each device to add appropriate tags like tag:server, tag:client, or tag:printer.

Note: Tags must be applied through the admin console web interface. Command-line tagging is not available for security reasons.

Configure custom DNS settings

Set up custom DNS resolution for your Tailscale network to resolve internal hostnames and improve performance.

sudo tailscale up --accept-dns=true

In the Tailscale admin console, go to DNS settings and configure:

  • Global nameservers: 1.1.1.1, 8.8.8.8
  • Split DNS: example.local -> 192.168.1.10
  • MagicDNS: Enabled (allows using device names like server.tail-scale.ts.net)

Enable key expiry and disable key expiry

Configure authentication key settings for enhanced security. By default, device keys expire after 180 days.

sudo tailscale up --auth-key=tskey-auth-xxxxx-xxxxxxxxxxxxxxxxxxxx

For servers that need persistent connectivity, disable key expiry in the admin console by selecting the device and clicking "Disable key expiry." For client devices, leave expiry enabled for better security.

Verify your setup

Check that Tailscale is running and connected to your network with proper routing configuration.

sudo tailscale status
sudo tailscale ip -4
sudo tailscale netcheck
ip route show | grep tailscale

Test connectivity to other devices on your Tailscale network and verify subnet routing is working.

ping 100.x.x.x  # Replace with another Tailscale device IP
ping 192.168.1.1  # Test subnet routing to local gateway
tailscale ping hostname.tail-scale.ts.net

Monitor and manage connections

Use these commands to monitor your Tailscale network and troubleshoot connectivity issues.

# View detailed status and connection info
sudo tailscale status --peers

Check network connectivity and NAT traversal

sudo tailscale netcheck

View logs for troubleshooting

sudo journalctl -u tailscaled -f

Test connection quality to specific peer

tailscale ping --verbose hostname.tail-scale.ts.net

View routing table

sudo tailscale status --json | jq '.Peer[] | {Name: .HostName, IP: .TailscaleIPs, Routes: .PrimaryRoutes}'

Common issues

Symptom Cause Fix
Subnet routes not working Routes not approved or IP forwarding disabled Approve routes in admin console and verify sudo sysctl net.ipv4.ip_forward returns 1
Can't connect to peers Firewall blocking Tailscale or NAT issues Run sudo tailscale netcheck and check firewall rules with sudo ufw status
Exit node not available Exit node not approved or offline Approve exit node in admin console and verify it's online with tailscale status
DNS resolution failing MagicDNS disabled or DNS settings incorrect Enable MagicDNS in admin console and run sudo tailscale up --accept-dns=true
ACL blocking connections Restrictive ACL policy or missing tags Check ACL syntax in admin console and verify device tags are applied correctly
Service won't start Conflicting VPN or network configuration Check for conflicts with sudo systemctl status tailscaled and review logs

Security best practices

Implement these security measures to harden your Tailscale deployment for production use.

Key expiry: Enable key expiry for client devices but consider disabling it for critical infrastructure servers that need persistent connectivity.

Regular ACL audits and user access reviews ensure your zero-trust policies remain effective. Consider implementing device approval workflows and enabling audit logging for compliance requirements.

# Enable HTTPS certificates for internal services
sudo tailscale cert example.tail-scale.ts.net

Use Tailscale SSH for secure access (requires ACL configuration)

tailscale ssh user@hostname.tail-scale.ts.net

Performance optimization

Optimize Tailscale performance for high-throughput scenarios and reduce latency between peers. These settings are particularly important when using subnet routing or exit nodes extensively.

# Enable direct connections and optimize for performance
sudo tailscale up --accept-routes --shields-up=false

Check for direct connections vs relayed

tailscale netcheck

For production deployments, consider implementing the network performance optimizations covered in our Linux network stack performance tuning guide.

Integration with existing infrastructure

Tailscale works alongside existing VPN solutions and can complement traditional network security tools. For environments with existing network monitoring, integrate Tailscale metrics with your monitoring stack.

When deploying in containerized environments, ensure proper network configuration as detailed in our process monitoring and resource management tutorial.

Next steps

Automated install script

Run this to automate the entire setup

#tailscale #mesh-vpn #subnet-routing #tailscale-acl #wireguard-mesh #zero-trust-network #tailscale-exit-node

Need help?

Don't want to manage this yourself?

We handle infrastructure for businesses that depend on uptime. From initial setup to ongoing operations.

Talk to an engineer