Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No SERVFAIL and no forwarding multicast names #86

Merged
merged 2 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ RUN \
&& git clone --depth 1 -b v${COREDNS_VERSION} https://github.com/coredns/coredns \
&& cp -rf plugins/* coredns/plugin/ \
&& cd coredns \
&& sed -i "/^template:template/d" plugin.cfg \
&& sed -i "/^hosts:.*/a template:template" plugin.cfg \
&& sed -i "/^forward:.*/i fallback:fallback" plugin.cfg \
&& sed -i "/^hosts:.*/a mdns:mdns" plugin.cfg \
&& sed -i "/route53:route53/d" plugin.cfg \
Expand Down
13 changes: 8 additions & 5 deletions plugins/mdns/mdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (m MDNS) AddARecord(msg *dns.Msg, state *request.Request, name string, addr
}

func (m MDNS) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
// If systemd-resolved isn't available, plugin can't do anything. Pass to the next one.
if m.Resolver == nil {
return plugin.NextOrFailure(m.Name(), m.Next, ctx, w, r)
}
Expand Down Expand Up @@ -99,14 +100,16 @@ func (m MDNS) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
// There may be uncommon errors though so not swallowing it while debugging
log.Debug(err)

} else if m.AddARecord(msg, &state, hostName, addresses) {
} else {
m.AddARecord(msg, &state, hostName, addresses)
log.Debug(msg)
w.WriteMsg(msg)
return dns.RcodeSuccess, nil
}

log.Debugf("No records found for '%s', forwarding to next plugin.", state.QName())
return plugin.NextOrFailure(m.Name(), m.Next, ctx, w, r)
// Plugin only processes A and AAAA type multicast queries (.local or single name)
// Whether an answer was found or not this is end of the line, do not forward to external resolvers
// Always return NOERROR since we are not authoritative for this domain
w.WriteMsg(msg)
return dns.RcodeSuccess, nil
}

func GetPrimaryInterface(ctx context.Context, resolver *resolve1.Manager) int32 {
Expand Down
3 changes: 3 additions & 0 deletions rootfs/usr/share/tempio/corefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
template ANY AAAA local.hass.io hassio {
rcode NOERROR
}
template ANY A local.hass.io hassio {
rcode NXDOMAIN
}
mdns
forward . {{ join " " .servers }} {{ if len .locals | eq 0 }}dns://127.0.0.11{{ else }}{{ join " " .locals }}{{ end }} {
except local.hass.io
Expand Down