Skip to content

Commit 5254e70

Browse files
committed
wgengine: return explicit lo0 for loopback addrs on sandboxed macOS (tailscale#15493)
fixes tailscale/corp#27506 The source address link selection on sandboxed macOS doesn't deal with loopback addresses correctly. This adds an explicit check to ensure we return the loopback interface for loopback addresses instead of the default empty interface. Specifically, this allows the dns resolver to route queries to a loopback IP which is a common tactic for local DNS proxies. Tested on both macos, macsys and tailscaled. Forwarded requests to 127/8 all bound to lo0. Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
1 parent 97f368a commit 5254e70

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

wgengine/userspace.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,12 @@ type fwdDNSLinkSelector struct {
15801580
}
15811581

15821582
func (ls fwdDNSLinkSelector) PickLink(ip netip.Addr) (linkName string) {
1583+
// sandboxed macOS does not automatically bind to the loopback interface so
1584+
// we must be explicit about it.
1585+
if runtime.GOOS == "darwin" && ip.IsLoopback() {
1586+
return "lo0"
1587+
}
1588+
15831589
if ls.ue.isDNSIPOverTailscale.Load()(ip) {
15841590
return ls.tunName
15851591
}

0 commit comments

Comments
 (0)