ori-edge / k8s_gateway

A CoreDNS plugin to resolve all types of external Kubernetes resources
Apache License 2.0
295 stars 63 forks source link

fallthrough and forward not working together #298

Open fafarun opened 1 month ago

fafarun commented 1 month ago

We used k8s_gateway as principal DNS server for servers.

We need to use fordward to send request to another Dns server for external domain, but my configuration doesn't works.

Config file

.:1053 {
    debug
     k8s_gateway mydomain.com {
        apex ext-rke2-coredns-k8s-gateway.kube-system
        ttl 300
        fallthrough mydomain.com externaldomain.com
     }
     log
     cache 30
     forward externaldomain.com 192.168.11.4
     errors
     health {
        lameduck 5s
     }
     ready
     loop
     reload
     loadbalance
     file /etc/coredns/mydomain.com.db
}
mydomain.com.db: 
----
$ORIGIN mydomain.com.
@       3600  IN  SOA sn.dns.icann.com. no.dns.icann.com. 2015082541  7200  3600  1209600 3600
        3600  IN  A   192.168.0.101 
ns01          IN  A   192.168.0.101

Dig response

; <<>> DiG 9.10.6 <<>> server01.externaldomain.com @192.168.0.101
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 11740
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;server01.externaldomain.com.   IN  A

;; AUTHORITY SECTION:
mydomain.com.       2   IN  SOA sn.dns.icann.com. no.dns.icann.com. 2015082541 7200 3600 1209600 3600

;; Query time: 4 msec
;; SERVER: 160.31.1.200#53(160.31.1.200)
;; WHEN: Tue Jul 09 09:50:04 CEST 2024
;; MSG SIZE  rcvd: 133

Log of pod :

[DEBUG] plugin/k8s_gateway: Request server01.externaldomain.com. has not matched any zones [mydomain.com.]
[INFO] 10.42.255.138:53702 - 51759 "A IN server01.externaldomain.com. udp 54 false 4096" NXDOMAIN qr,aa,rd 122 0.000440085s

If i remove the fallthrough section, the forward works.

Someone can help me to understand where i make a mistake.