Tailscale WireGuard Linux Split Tunneling Plan
In this article
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
- 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.
- 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.
- 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=1andsudo tailscale up --advertise-routes=192.168.1.0/24(replace with your actual subnet). Then, in the Tailscale admin console, approve the advertised routes. - On your Linux client, accept the subnet routes. When you run
sudo tailscale up, add the flag--accept-routesto 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. - 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 runningsudo tailscale up --exit-node=(empty) or omit the exit node flag. - 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 100andsudo ip route add default dev tailscale0 table 100. - Make policy routing persistent. Since
ipcommands 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 useiptableswith theip-rulemodule. Alternatively, use a tool liketailscale up --accept-routescombined withip ruleand save them vianetplanorNetworkManagerdispatcher scripts. - Test your split tunneling. Use
tracerouteorip route getto 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.5should showdev tailscale0, whileip route get 8.8.8.8should show your regular interface. - 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
dnsmasqto 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 upwith an exit node earlier, it will route all traffic through the tunnel, defeating split tunneling. Always check your current Tailscale settings withtailscale statusand 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.
ipcommands are lost on reboot. If you don't make them persistent, your split tunneling will break after a restart.
Tips
- Use
tailscale pingto test connectivity to a device on the remote subnet before worrying about routing. - For debugging, run
tailscale statusto 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
--snatoption 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 routeto 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 showto 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
ipcommands 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
digornslookupto 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.