dnsfallback

package
v1.106.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: BSD-3-Clause Imports: 25 Imported by: 6 modules, 18 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

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

It resolves Tailscale's own hostnames by asking DERP servers over HTTPS. We're slowly removing it in favor of caching earlier DNS results on disk (feature/dnsresolvecache); see https://github.com/tailscale/tailscale/issues/21028.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDERPMap added in v1.72.0

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 added in v1.40.0

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 and to fail fast when no network interface is up.

The returned func only resolves Tailscale's own hostnames (see fallbacknames.IsTailscaleHost). For any other name it returns an error wrapping dnscache.ErrNoFallback, so a dnscache.Resolver returns its original error instead.

func SetCachePath added in v1.32.0

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 added in v1.32.0

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.

Types

This section is empty.

Directories

Path Synopsis
Package fallbacknames defines which hostnames the DERP-based fallback DNS mechanism (net/dnsfallback and the DERP server's /bootstrap-dns handler) is allowed to resolve.
Package fallbacknames defines which hostnames the DERP-based fallback DNS mechanism (net/dnsfallback and the DERP server's /bootstrap-dns handler) is allowed to resolve.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL