With an exit node, table 52's default route makes strict reverse path filtering drop replies to tailscaled's own sockets: the kernel checks a reply's source with a reverse lookup, as uid 0 from the underlay address, which finds the default route via the Tailscale interface rather than the one the reply arrived on (#3310). The reverted src_valid_mark=1 workaround fixed that for the whole host and broke every other fwmark user (#19796). Instead, while 0.0.0.0/0 or ::/0 is routed into table 52, install per address family: pref base+55: not fwmark <bypass> lookup 52 suppress_prefixlength 0 pref base+60: from A uidrange 0-0 lookup main with a base+60 rule for each underlay address A. base+60 sends the reverse lookup to the main table, and base+55 keeps table 52's tailnet and LAN routes ahead of it, so tailnet peers still reach A through the tunnel and ExitNodeAllowLANAccess=false still blocks the LAN. IPv6, which has no kernel rp_filter, gets its rules whenever ::/0 is routed. The IPv4 rules only exist while rp_filter is strict somewhere, re-read every 10s while an exit node is in use since a sysctl write raises no event. The rules are added before the exit node's default route and removed after it is gone, and in Close. They follow netmon's interface state, for at most 128 addresses per family and never for our own Tailscale addresses. They carry rule protocol 52; Up and tailscaled's startup cleanup sweep away any a previous instance left. They don't use netfilter, so they work in every netfilter mode. TS_DEBUG_DISABLE_RPFILTER_SRC_RULES=true turns them off. The router ignores deletions at their priorities instead of restoring the base rules, since those deletions are its own. linuxfw documents that the connmark rules only help reverse path checks that are mark-aware. Follow-ups cover replies from LAN peers to the magicsock port with LAN access off, and rules other processes delete. Not covered, and pinned by tests: remotes that a more specific table 52 route covers, such as an accepted subnet route, and IPv4 netfilter reverse path checks without a strict kernel rp_filter. Nor are hosts whose underlay default route is not in main. Behavior change: while an exit node is in use, sockets of root processes bound to an underlay address, and packets the kernel itself sends from one, leave by the physical interface rather than the exit node; non-root processes are unaffected. That holds for IPv6 on every host and for IPv4 where rp_filter is strict. Hosts that ran a release with the reverted change keep src_valid_mark=1 until reboot or reset. RELNOTE: Linux: exit nodes no longer set src_valid_mark=1; root sockets bound to a physical interface's address now bypass the exit node. Updates #3310 Updates #19796 Signed-off-by: Mike O'Driscoll <[email protected]>
Tailscale
Private WireGuard® networks made easy
Overview
This repository contains the majority of Tailscale's open source code.
Notably, it includes the tailscaled daemon and
the tailscale CLI tool. The tailscaled daemon runs on Linux, Windows,
macOS, and to varying degrees
on FreeBSD and OpenBSD. The Tailscale iOS and Android apps use this repo's
code, but this repo doesn't contain the mobile GUI code.
Other Tailscale repos of note:
- the Android app is at https://github.com/tailscale/tailscale-android
- the Synology package is at https://github.com/tailscale/tailscale-synology
- the QNAP package is at https://github.com/tailscale/tailscale-qpkg
- the Chocolatey packaging is at https://github.com/tailscale/tailscale-chocolatey
For background on which parts of Tailscale are open source and why, see https://tailscale.com/opensource/.
Using
We serve packages for a variety of distros and platforms at https://pkgs.tailscale.com.
Other clients
The macOS, iOS, and Windows clients use the code in this repository but additionally include small GUI wrappers. The GUI wrappers on non-open source platforms are themselves not open source.
Building
We always require the latest Go release, currently Go 1.27. (While we build releases with our Go fork, its use is not required.)
go install tailscale.com/cmd/tailscale{,d}
If you're packaging Tailscale for distribution, use build_dist.sh
instead, to burn commit IDs and version info into the binaries:
./build_dist.sh tailscale.com/cmd/tailscale
./build_dist.sh tailscale.com/cmd/tailscaled
If your distro has conventions that preclude the use of
build_dist.sh, please do the equivalent of what it does in your
distro's way, so that bug reports contain useful version information.
Bugs
Please file any issues about this code or the hosted service on the issue tracker.
Contributing
PRs welcome! But please file bugs. Commit messages should reference bugs.
We require Developer Certificate of
Origin
Signed-off-by lines in commits.
See commit-messages.md (or skim git log) for our commit message style.
About Us
Tailscale is primarily developed by the people at https://github.com/orgs/tailscale/people. For other contributors, see:
- https://github.com/tailscale/tailscale/graphs/contributors
- https://github.com/tailscale/tailscale-android/graphs/contributors
Legal
WireGuard is a registered trademark of Jason A. Donenfeld.