Use a Linux machine as a Tailscale subnet router to give your tailnet devices access to networks behind an OpenVPN tunnel.
[ Phone/Tablet ]
|
(tailnet)
|
[ Linux box ] ---- OpenVPN (tun0) ----> [ Remote network 10.x.x.x ]
Your Linux machine is connected to a remote network via OpenVPN. You want other devices on your Tailscale network (phone, laptop, etc.) to reach hosts on that remote network — without installing a VPN client on each device.
- Linux machine with both Tailscale and OpenVPN running
- IP forwarding enabled:
sysctl -w net.ipv4.ip_forward=1(and persisted in/etc/sysctl.conf)
tailscale up --advertise-routes=10.0.1.0/24Adjust the CIDR to match whichever subnets you need to reach. Then approve the route in the Tailscale admin console.
This is the non-obvious part. Forwarding alone isn't enough.
When your phone sends a packet to 10.0.1.50, it arrives on tailscale0 with a source address of 100.x.x.x (your phone's Tailscale IP). The packet gets forwarded out tun0 to the remote network. But the remote network has no route back to 100.x.x.x, so the reply is silently dropped.
The fix is to MASQUERADE outbound traffic on tun0:
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADEThis rewrites the source IP to the Linux machine's tun0 address, so the remote side knows how to reply. The Linux box then de-NATs the return traffic and forwards it back through Tailscale.
Note: If you have both
iptables-nftandiptables-legacyon your system, make sure you're adding the rule to whichever backend your other rules (Docker, Tailscale, etc.) are using. Check withiptables-nft -L FORWARD -v -nvsiptables-legacy -L FORWARD -v -n.
The MASQUERADE rule won't survive a reboot. If your OpenVPN connection is managed by NetworkManager, a dispatcher script is a clean way to tie the rule to the tunnel lifecycle:
/etc/NetworkManager/dispatcher.d/50-tailscale-masquerade
#!/bin/bash
INTERFACE="$1"
ACTION="$2"
if [ "$INTERFACE" != "tun0" ]; then
exit 0
fi
case "$ACTION" in
up)
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
;;
down)
iptables -t nat -D POSTROUTING -o tun0 -j MASQUERADE
;;
esacsudo chmod 755 /etc/NetworkManager/dispatcher.d/50-tailscale-masqueradeIf you manage OpenVPN differently (systemd, command line), you can use the --up / --down script options in your .ovpn config, or just add the iptables rule to /etc/rc.local.
- Check forwarding:
cat /proc/sys/net/ipv4/ip_forward— must be1 - Check routes:
ip route— make sure the target subnet routes throughtun0 - Check Tailscale:
tailscale status— confirm your devices are online and routes are advertised - Check iptables FORWARD chain: Docker, Calico, Multipass, etc. all add FORWARD rules. Make sure traffic between
tailscale0andtun0isn't being dropped. Look at thets-forwardchain if it exists. - Check NAT rule is active:
iptables -t nat -L POSTROUTING -v -n— you should see the MASQUERADE rule ontun0