Send search domains
@@ -241,11 +241,27 @@ func (h *Headscale) getMapResponse(mKey wgkey.Key, req tailcfg.MapRequest, m Mac
DisplayName: m.Namespace.Name,
}
+ var dnsConfig *tailcfg.DNSConfig
+ if h.cfg.DNSConfig.Proxied { // if MagicDNS is enabled
+ // TODO(juanfont): We should not be regenerating this all the time
+ // And we should only send the domains of the peers (this own namespace + those from the shared peers)
+ namespaces, err := h.ListNamespaces()
+ if err != nil {
+ return nil, err
+ }
+ dnsConfig := h.cfg.DNSConfig.Clone()
+ for _, ns := range *namespaces {
+ dnsConfig.Domains = append(dnsConfig.Domains, fmt.Sprintf("%s.%s", ns.Name, h.cfg.BaseDomain))
+ }
+ } else {
+ dnsConfig = h.cfg.DNSConfig
+ }
+
resp := tailcfg.MapResponse{
KeepAlive: false,
Node: node,
Peers: *peers,
- DNSConfig: h.cfg.DNSConfig,
+ DNSConfig: dnsConfig,
Domain: h.cfg.BaseDomain,
PacketFilter: *h.aclRules,
DERPMap: h.cfg.DerpMap,
