Skip to content

Commit 2bfef27

Browse files
mtparetclaude
andcommitted
cmd/containerboot: fix Service routing by trusting DNS ExtraRecords
Tailscale Services are identified by DNS ExtraRecords, not by AllowedIPs advertisements from peers. The previous implementation required finding the Service IP in a peer's AllowedIPs, which never matches because Services don't work like subnet routes. This fix removes the incorrect AllowedIPs validation and trusts the ExtraRecords directly, allowing egress proxies to properly route traffic to Tailscale Services. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f427e77 commit 2bfef27

1 file changed

Lines changed: 7 additions & 25 deletions

File tree

cmd/containerboot/main.go

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -906,40 +906,22 @@ func resolveTailnetFQDN(nm *netmap.NetworkMap, fqdn string) ([]netip.Prefix, err
906906
}
907907

908908
// serviceIPsFromNetMap returns all IPs of a Tailscale Service if its FQDN is
909-
// found in the netmap. Note that Tailscale Services are not a first-class
910-
// object in the netmap, so we guess based on DNS ExtraRecords and AllowedIPs.
909+
// found in the netmap's DNS ExtraRecords. Tailscale Services are identified by
910+
// their DNS records rather than AllowedIPs advertisements from peers.
911911
func serviceIPsFromNetMap(nm *netmap.NetworkMap, fqdn dnsname.FQDN) []netip.Prefix {
912-
var extraRecords []tailcfg.DNSRecord
912+
var prefixes []netip.Prefix
913913
for _, rec := range nm.DNS.ExtraRecords {
914914
recFQDN, err := dnsname.ToFQDN(rec.Name)
915915
if err != nil {
916916
continue
917917
}
918918
if strings.EqualFold(fqdn.WithTrailingDot(), recFQDN.WithTrailingDot()) {
919-
extraRecords = append(extraRecords, rec)
920-
}
921-
}
922-
923-
if len(extraRecords) == 0 {
924-
return nil
925-
}
926-
927-
// Validate we can see a peer advertising the Tailscale Service.
928-
var prefixes []netip.Prefix
929-
for _, extraRecord := range extraRecords {
930-
ip, err := netip.ParseAddr(extraRecord.Value)
931-
if err != nil {
932-
continue
933-
}
934-
ipPrefix := netip.PrefixFrom(ip, ip.BitLen())
935-
for _, ps := range nm.Peers {
936-
for _, allowedIP := range ps.AllowedIPs().All() {
937-
if allowedIP == ipPrefix {
938-
prefixes = append(prefixes, ipPrefix)
939-
}
919+
ip, err := netip.ParseAddr(rec.Value)
920+
if err != nil {
921+
continue
940922
}
923+
prefixes = append(prefixes, netip.PrefixFrom(ip, ip.BitLen()))
941924
}
942925
}
943-
944926
return prefixes
945927
}

0 commit comments

Comments
 (0)