Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Tailscale WireGuard Linux Split Tunneling Plan

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide explains how to plan and implement split tunneling with Tailscale on Linux, where only specific traffic goes through the WireGuard-based Tailscale network while the rest uses your regular internet connection. You'll learn how to design your routing, configure Tailscale's ACLs and subnet routes, and use Linux routing rules to achieve precise control over which destinations use the tunnel.

What You'll Need

  • A Linux machine (Debian/Ubuntu, Fedora, Arch, etc.) with systemd or similar init system
  • Tailscale installed and logged in (tailscale up)
  • Root or sudo access on the Linux machine
  • Basic familiarity with the command line and IP routing concepts
  • If you need to route traffic to other devices on your tailnet, those devices must be advertising subnet routes (or you'll use Tailscale's exit node feature)

Step-by-Step

  1. Define your split tunneling goals. Decide exactly which traffic should go through Tailscale. Common patterns: (a) route only traffic to specific internal IP ranges (e.g., 192.168.1.0/24) through the tunnel, (b) use a specific exit node for only certain domains or IPs, (c) route all traffic except a few destinations through the tunnel. Write down the destination IPs or CIDRs you want to tunnel.
  2. Choose your approach. Tailscale offers two main mechanisms for split tunneling: subnet routes (advertised by a device on your tailnet) and exit nodes (route all traffic to a specific node). For split tunneling, you'll typically use subnet routes, because they let you target specific destination networks. If you need to tunnel only certain domains, you'll need to resolve them to IPs and use those IPs in your routing rules.
  3. Set up subnet routes on the remote device. On the device that has access to the target network (e.g., your home router or a server), enable IP forwarding and advertise the subnet: sudo sysctl -w net.ipv4.ip_forward=1 and sudo tailscale up --advertise-routes=192.168.1.0/24 (replace with your actual subnet). Then, in the Tailscale admin console, approve the advertised routes.
  4. On your Linux client, accept the subnet routes. When you run sudo tailscale up, add the flag --accept-routes to accept routes advertised by other devices. This will automatically add routes to the Tailscale interface for those subnets, but by default it may route all traffic if you also have an exit node. For split tunneling, do not use an exit node unless you intend to route everything.
  5. Verify the automatic routes. Check the routing table with ip route. You should see routes for the advertised subnets pointing to the tailscale0 interface (e.g., 192.168.1.0/24 dev tailscale0). If you see a default route via tailscale0, that means you're using an exit node; remove it by running sudo tailscale up --exit-node= (empty) or omit the exit node flag.
  6. For fine-grained control, use policy routing. If you need to tunnel only specific IPs or ports, or if you want to exclude some destinations from the tunnel, you'll need to use Linux policy routing. Create a new routing table (e.g., table 100) and add a rule that sends traffic for your target destinations to that table, which has a default route via tailscale0. Example: sudo ip rule add to 192.168.1.0/24 lookup 100 and sudo ip route add default dev tailscale0 table 100.
  7. Make policy routing persistent. Since ip commands are temporary, you'll need to make them persistent. On systemd-based systems, create a systemd service or use a network dispatcher script. A simple approach is to add the commands to a script that runs at boot, or use iptables with the ip-rule module. Alternatively, use a tool like tailscale up --accept-routes combined with ip rule and save them via netplan or NetworkManager dispatcher scripts.
  8. Test your split tunneling. Use traceroute or ip route get to verify that traffic to your target subnet goes through tailscale0, and that other traffic uses your normal interface. For example: ip route get 192.168.1.5 should show dev tailscale0, while ip route get 8.8.8.8 should show your regular interface.
  9. Consider DNS and domain-based routing. If you want to tunnel only specific domains, you'll need to resolve them to IPs and add those IPs to your routing rules. This is not automatic with Tailscale; you'll need to use a script or a tool like dnsmasq to update routes when IPs change. For most cases, using subnet CIDRs is simpler and more stable.

Common Mistakes

  • Using an exit node unintentionally. If you ran tailscale up with an exit node earlier, it will route all traffic through the tunnel, defeating split tunneling. Always check your current Tailscale settings with tailscale status and remove any exit node if not needed.
  • Not accepting routes on the client. Without --accept-routes, your client will ignore advertised subnet routes, so traffic to those subnets will go out the normal interface.
  • Forgetting to approve routes in the admin console. Subnet routes are not active until they are approved in the Tailscale admin console. If you don't see the route on your client, check the console.
  • Overlapping routes. If your local LAN uses the same IP range as the remote subnet, traffic will conflict. Use a different subnet on one side or use more specific routes.
  • Policy routing rules not persistent. ip commands are lost on reboot. If you don't make them persistent, your split tunneling will break after a restart.

Tips

  • Use tailscale ping to test connectivity to a device on the remote subnet before worrying about routing.
  • For debugging, run tailscale status to see the current routes and exit node.
  • If you need to tunnel only a few IPs, use a single /32 route for each IP rather than a broad subnet to minimize routing conflicts.
  • Consider using Tailscale's --snat option on the subnet router if you have routing issues with the remote network.
  • Document your routing rules in a script or comment so you can easily reapply them after a system update.

Troubleshooting

  • Traffic is not going through the tunnel. Check ip route to see if the route exists. If not, verify that the subnet router is advertising and that you've accepted routes. Also check the admin console for route approval.
  • All traffic is going through the tunnel. You likely have an exit node set. Run sudo tailscale up --exit-node= to clear it, or edit your Tailscale config to remove the exit node.
  • Policy routing rules are not working. Ensure the rule is in the correct order. Use ip rule show to verify. Also check that the routing table (e.g., 100) has the default route via tailscale0.
  • After reboot, routing is gone. Make your rules persistent. Create a systemd service that runs the ip commands at boot, or use a network dispatcher script.
  • DNS for remote domains is not resolving. If you're tunneling based on domains, you need to resolve them to IPs. Use dig or nslookup to get the IP and add a route for that IP. Alternatively, set up a DNS server on the remote network and use Tailscale's MagicDNS for internal names.

Frequently Asked Questions

Can I split tunnel based on domain names instead of IPs?

Tailscale does not natively support domain-based routing. You can resolve domains to IPs and add routes for those IPs, but the IPs may change. For dynamic domains, you'd need a script to update routes periodically.

Do I need a separate WireGuard configuration?

No, Tailscale uses WireGuard under the hood, but it manages the keys and configuration automatically. You don't need to manually set up WireGuard interfaces.

Can I use split tunneling with an exit node?

Yes, but you'll need to use policy routing to exclude certain destinations from the exit node. By default, an exit node routes all traffic, so you'd need to add rules to send specific traffic out the normal interface instead.

Will split tunneling affect my VPN speed?

Only traffic that goes through the tunnel is affected by VPN latency and throughput. Other traffic uses your normal connection, so speed is unchanged for those destinations.

How do I make my routing rules survive a reboot?

Create a systemd service that runs your ip commands at boot, or use a network dispatcher script if you're using NetworkManager. Alternatively, you can use netplan for static routes on Ubuntu.

Is it possible to tunnel only specific ports?

Yes, using iptables with the ip-rule module, you can match ports and send them to a specific routing table. For example, you can route only TCP port 22 to the tunnel.