tailscale.comtailscale.com/net/dnsfallback Index | Files

package dnsfallback

import "tailscale.com/net/dnsfallback"

Package dnsfallback contains a DNS fallback mechanism for starting up Tailscale when the system DNS is broken or otherwise unavailable.

The data is backed by a JSON file `dns-fallback-servers.json` that is updated by `update-dns-fallbacks.go`:

(cd net/dnsfallback; go run update-dns-fallbacks.go)

Index

Functions

func GetDERPMap

func GetDERPMap() *tailcfg.DERPMap

GetDERPMap returns a fallback DERP map that is always available, useful for basic bootstrapping purposes. The dynamically updated DERP map in LocalBackend should always be preferred over this. Use this DERP map only when the control plane is unreachable or hasn't been reached yet. The DERP servers in the returned map also run a fallback DNS server.

func MakeLookupFunc

func MakeLookupFunc(logf logger.Logf, netMon *netmon.Monitor) func(ctx context.Context, host string) ([]netip.Addr, error)

MakeLookupFunc creates a function that can be used to resolve hostnames (e.g. as a LookupIPFallback from dnscache.Resolver). The netMon parameter is optional; if non-nil it's used to do faster interface lookups.

func SetCachePath

func SetCachePath(path string, logf logger.Logf)

SetCachePath sets the path to the on-disk DERP map cache that we store and update. Additionally, if a file at this path exists, we load it and merge it with the DERP map baked into the binary.

This function should be called before any calls to UpdateCache, as it is not concurrency-safe.

func UpdateCache

func UpdateCache(c *tailcfg.DERPMap, logf logger.Logf)

UpdateCache stores the DERP map cache back to disk.

The caller must not mutate 'c' after calling this function.

Source Files

dnsfallback.go

Version
v1.84.0 (latest)
Published
May 21, 2025
Platform
linux/amd64
Imports
27 packages
Last checked
57 seconds ago

Tools for package owners.