cmd/tailscale: use Google as DNS of last resort

Sometimes we try a dozen different ways to read the phone's DNS
settings and it still comes back empty. In that case, if we're already
on a Google-ified Android phone, just use Google's Public DNS servers
as the ultimate fallback, as we already do on ChromeOS to work around
ChromeOS Android VpnBuilder bugs.

Updates tailscale/tailscale#8006 etc etc

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
bradfitz/bump_tscom
Brad Fitzpatrick 2 years ago committed by Brad Fitzpatrick
parent 13ecd3e34d
commit a7b3ae04b0

@ -426,7 +426,19 @@ func (b *backend) getPlatformDNSConfig() string {
return baseConfig
}
func (b *backend) getDNSBaseConfig() (dns.OSConfig, error) {
func (b *backend) getDNSBaseConfig() (ret dns.OSConfig, _ error) {
defer func() {
// If we couldn't find any base nameservers, ultimately fall back to
// Google's. Normally Tailscale doesn't ever pick a default nameserver
// for users but in this case Android's APIs for reading the underlying
// DNS config are lacking, and almost all Android phones use Google
// services anyway, so it's a reasonable default: it's an ecosystem the
// user has selected by having an Android device.
if len(ret.Nameservers) == 0 && googleSignInEnabled() {
log.Printf("getDNSBaseConfig: none found; falling back to Google public DNS")
ret.Nameservers = append(ret.Nameservers, googleDNSServers...)
}
}()
b.logDNSConfigMechanisms()
baseConfig := b.getPlatformDNSConfig()
lines := strings.Split(baseConfig, "\n")

Loading…
Cancel
Save