You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The priority of domain name resolution set separately is higher than that of generic domain name resolution.
and in this Corefile:
b.com:53 {
errors
cache 10
loadbalance
hosts {
1.2.3.4 r1.b.com
2.3.4.5 r1.b.com
fallthrough
}
template IN A b.com {
match .*\.b\.com
answer "{{ .Name }} 60 IN A 11.22.33.44"
answer "{{ .Name }} 60 IN A 22.33.44.55"
fallthrough
}
I resolve r1.b.com, which will response 11.22.33.44 and 22.33.44.55. in fact I need to get 1.2.3.4 and 2.3.4.5.
I found the reason is plugins order in plugin.cfg.
and now
...
template:template
...
hosts:hostsconf
...
so maybe we need change the order about template and. hosts plugins.
The text was updated successfully, but these errors were encountered:
Yes, you can change the order of the items in plugin.cfg if you want your host plugin answers to take precedence over the template plugin answers. This requires re-building coredns and using that custom image/binary.
Another less optimal* way to solve it but doesn't require a re-build is to use self forwarding to a second server block listening on a separate port:
b.com:53 {
hosts {
1.2.3.4 r1.b.com
2.3.4.5 r1.b.com
fallthrough
}
forward . localhost:5300
}
b.com:5300 {
template IN A b.com {
match .*\.b\.com
answer "{{ .Name }} 60 IN A 11.22.33.44"
answer "{{ .Name }} 60 IN A 22.33.44.55"
fallthrough
}
forward . /etc/resolv.conf
}
* less optimal because it introduces an extra hop.
@chrisohaver thanks for your immediate and detailed reply, it works for me.
Bytheway is this plugin's order need to change in this repo ?, maybe generic resolve record higher than accurate resolve record violates DNS rules.
Bytheway is this plugin's order need to change in this repo ?, maybe generic resolve record higher than accurate resolve record violates DNS rules.
We should not change it in this repo. If we were to do so, it would be a backward incompatible change for those who rely on the current order. The current behavior does not violate DNS rules.
A very different way to solve your example without a re-build is using the file plugin with it's zonefile containing wildcard A records for *.b.com, and normal A records for r1.b.com. This would not require the self-forwarding trick (or the hosts plugin). This is a cleaner solution than using hosts in conjunction with template.
The priority of domain name resolution set separately is higher than that of generic domain name resolution.
and in this Corefile:
b.com:53 { errors cache 10 loadbalance hosts { 1.2.3.4 r1.b.com 2.3.4.5 r1.b.com fallthrough } template IN A b.com { match .*\.b\.com answer "{{ .Name }} 60 IN A 11.22.33.44" answer "{{ .Name }} 60 IN A 22.33.44.55" fallthrough }
I resolve r1.b.com, which will response 11.22.33.44 and 22.33.44.55. in fact I need to get 1.2.3.4 and 2.3.4.5.
I found the reason is plugins order in plugin.cfg.
and now
so maybe we need change the order about template and. hosts plugins.
The text was updated successfully, but these errors were encountered: