diff --git a/app.go b/app.go index 0576e7f2..66e2a306 100644 --- a/app.go +++ b/app.go @@ -113,7 +113,8 @@ func NewHeadscale(cfg Config) (*Headscale, error) { if err != nil { return nil, err } - if h.cfg.DNSConfig.Routes == nil { // we might have routes already from Split DNS + // we might have routes already from Split DNS + if h.cfg.DNSConfig.Routes == nil { h.cfg.DNSConfig.Routes = make(map[string][]dnstype.Resolver) } for _, d := range magicDNSDomains { diff --git a/cmd/headscale/cli/utils.go b/cmd/headscale/cli/utils.go index 7b7d84ad..52c8d043 100644 --- a/cmd/headscale/cli/utils.go +++ b/cmd/headscale/cli/utils.go @@ -109,9 +109,9 @@ func GetDNSConfig() (*tailcfg.DNSConfig, string) { if len(dnsConfig.Nameservers) > 0 { dnsConfig.Routes = make(map[string][]dnstype.Resolver) restrictedDNS := viper.GetStringMapStringSlice("dns_config.restricted_nameservers") - for domain, resNameservers := range restrictedDNS { - resResolvers := make([]dnstype.Resolver, len(resNameservers)) - for index, nameserverStr := range resNameservers { + for domain, restrictedNameservers := range restrictedDNS { + restrictedResolvers := make([]dnstype.Resolver, len(restrictedNameservers)) + for index, nameserverStr := range restrictedNameservers { nameserver, err := netaddr.ParseIP(nameserverStr) if err != nil { log.Error(). @@ -119,11 +119,11 @@ func GetDNSConfig() (*tailcfg.DNSConfig, string) { Err(err). Msgf("Could not parse restricted nameserver IP: %s", nameserverStr) } - resResolvers[index] = dnstype.Resolver{ + restrictedResolvers[index] = dnstype.Resolver{ Addr: nameserver.String(), } } - dnsConfig.Routes[domain] = resResolvers + dnsConfig.Routes[domain] = restrictedResolvers } } else { log.Warn(). diff --git a/docs/DNS.md b/docs/DNS.md index 948f3c79..10f99b79 100644 --- a/docs/DNS.md +++ b/docs/DNS.md @@ -36,4 +36,4 @@ dns_config: - `domains`: Search domains to inject. - `magic_dns`: Whether to use [MagicDNS](https://tailscale.com/kb/1081/magicdns/). Only works if there is at least a nameserver defined. - `base_domain`: Defines the base domain to create the hostnames for MagicDNS. `base_domain` must be a FQDNs, without the trailing dot. The FQDN of the hosts will be `hostname.namespace.base_domain` (e.g., _myhost.mynamespace.example.com_). -- `restricted_nameservers`: Also known as Split DNS (see https://tailscale.com/kb/1054/dns/), list of search domains and the DNS you want to use for them. \ No newline at end of file +- `restricted_nameservers`: Split DNS (see https://tailscale.com/kb/1054/dns/), list of search domains and the DNS to query for each one. \ No newline at end of file