wenerme/wps

CoreDNS pdsql + pdsql_sqlite: [ERROR] plugin/errors: 0 example.io. SOA: dns: domain must be fully qualified

Closed this issue · 0 comments

kmott commented

Hello,

I am trying to convert my old PowerDNS servers to CoreDNS using your pdsql + sqlite plugin, but am running into a few issues (I probably have something mis-configured). I'm testing out basic SOA and NS records, but I can't seem to get them working.

Here's what my Corefile looks like:

#
# Authoritative Server
#
example.io. {
    pdsql sqlite3 /path/to/example.io.db {
        debug db
        auto-migrate
    }
    log
    errors
    cache
}

#
# Default Recursors Forward
#
. {
    forward . 2620:0:ccc::2 2620:0:ccd::2 208.67.222.222 208.67.220.220
    cache
    errors
    log
}

And here's some debug logs from coredns:

coredns.default(SV): Starting service as user=root, group=root
coredns.default(O): pdsql enable log [db]
coredns.default(O): 
coredns.default(O): (/root/go/pkg/mod/github.com/wenerme/wps@v0.0.0-20191105094758-5c216d826ac7/coredns/plugin/pdsql/setup.go:77) 
coredns.default(O): [2020-01-26 19:00:38]  [8.28ms]  ALTER TABLE "records" ADD "chang_date" integer;  
coredns.default(O): [0 rows affected or returned ] 
coredns.default(O): pdsql enable log [db]
coredns.default(O): 
coredns.default(O): (/root/go/pkg/mod/github.com/wenerme/wps@v0.0.0-20191105094758-5c216d826ac7/coredns/plugin/pdsql/setup.go:77) 
coredns.default(O): [2020-01-26 19:00:38]  [7.66ms]  ALTER TABLE "records" ADD "chang_date" integer;  
coredns.default(O): [0 rows affected or returned ] 
coredns.default(O): .:5300
coredns.default(O): example.io.:5300
coredns.default(O): CoreDNS-1.6.6
coredns.default(O): linux/amd64, go1.13.5, 
coredns.default(O): 
coredns.default(O): (/root/go/pkg/mod/github.com/wenerme/wps@v0.0.0-20191105094758-5c216d826ac7/coredns/plugin/pdsql/pdsql.go:47) 
coredns.default(O): [2020-01-26 19:00:40]  [0.92ms]  SELECT * FROM "records"  WHERE ("records"."name" = 'example.io') AND ("records"."type" = 'SOA')  
coredns.default(O): [1 rows affected or returned ] 
coredns.default(O): [INFO] 172.17.0.1:32791 - 57123 "SOA IN example.io. udp 51 false 4096" NOERROR qr,aa,rd 85 0.002235243s
coredns.default(O): [ERROR] plugin/errors: 0 example.io. SOA: dns: domain must be fully qualified
coredns.default(O): [INFO] 172.17.0.1:39025 - 30550 "SOA IN example.io. udp 51 false 4096" NOERROR qr,aa,rd 105 0.00005859s
coredns.default(O): [INFO] 172.17.0.1:50535 - 56311 "SOA IN example.io. udp 51 false 4096" NOERROR qr,aa,rd 105 0.000117065s
coredns.default(O): [INFO] 172.17.0.1:50535 - 56311 "SOA IN example.io. udp 51 false 4096" NOERROR qr,aa,rd 105 0.00010024s
coredns.default(O): [INFO] 172.17.0.1:50535 - 56311 "SOA IN example.io. udp 51 false 4096" NOERROR qr,aa,rd 105 0.000046453s
coredns.default(O): 
coredns.default(O): (/root/go/pkg/mod/github.com/wenerme/wps@v0.0.0-20191105094758-5c216d826ac7/coredns/plugin/pdsql/pdsql.go:47) 
coredns.default(O): [2020-01-26 19:01:04]  [0.33ms]  SELECT * FROM "records"  WHERE ("records"."name" = 'example.io') AND ("records"."type" = 'NS')  
coredns.default(O): [2 rows affected or returned ] 
coredns.default(O): [INFO] 172.17.0.1:56110 - 35718 "NS IN example.io. udp 51 false 4096" NOERROR qr,aa,rd 73 0.000469583s
coredns.default(O): [ERROR] plugin/errors: 0 example.io. NS: dns: domain must be fully qualified
coredns.default(O): [INFO] 172.17.0.1:56110 - 35718 "NS IN example.io. udp 51 false 4096" NOERROR qr,aa,rd 102 0.000095002s
coredns.default(O): [INFO] 172.17.0.1:56110 - 35718 "NS IN example.io. udp 51 false 4096" NOERROR qr,aa,rd 102 0.000108018s

This is what dig reports:

dig -p 5300 @localhost example.io SOA

; <<>> DiG 9.14.8 <<>> -p 5300 @localhost example.io SOA
; (1 server found)
;; global options: +cmd
;; connection timed out; no servers could be reached

And here's what my sqlite database for domains & records looks like:

sqlite3 /path/to/example.io.db -line 'SELECT * FROM "domains";'
             id = 1
           name = example.io
         master = 1
     last_check = 
           type = NATIVE
notified_serial = 2020026068
        account = 


sqlite3 /path/to/example.io.db -line 'SELECT * FROM "records";'
         id = 1
  domain_id = 1
       name = example.io
       type = SOA
    content = ns1.example.io support.example.io 2020083356 10800 3600 604800 3600
        ttl = 3600
       prio = 0
 chang_date = 
   disabled = 0
 chang_date = 

         id = 2
  domain_id = 1
       name = example.io
       type = NS
    content = ns1.example.io
        ttl = 3600
       prio = 0
 chang_date = 
   disabled = 0
 chang_date = 

         id = 3
  domain_id = 1
       name = example.io
       type = NS
    content = ns2.example.io
        ttl = 3600
       prio = 0
 chang_date = 
   disabled = 0
 chang_date = 

         id = 4
  domain_id = 1
       name = ns1.example.io
       type = A
    content = 192.168.1.1
        ttl = 3600
       prio = 0
 chang_date = 
   disabled = 0
 chang_date = 

         id = 5
  domain_id = 1
       name = ns2.example.io
       type = A
    content = 192.168.1.2
        ttl = 3600
       prio = 0
 chang_date = 
   disabled = 0
 chang_date = 

         id = 6
  domain_id = 1
       name = bar.example.io
       type = CNAME
    content = google.com
        ttl = 3600
       prio = 0
 chang_date = 
   disabled = 0
 chang_date = 

The sqlite entries above very closely mimic my existing MySQL powerdns schema, here's a snippet of my existing MySQL data, with domain values sanitized:

MariaDB [powerdns]> select * from records where domain_id=1;
+----------+-----------+----------------+------+---------------------------------------------------------------------+------+------+-------------+----------+-----------+------+
| id       | domain_id | name           | type | content                                                             | ttl  | prio | change_date | disabled | ordername | auth |
+----------+-----------+----------------+------+---------------------------------------------------------------------+------+------+-------------+----------+-----------+------+
|        2 |         1 | example.io     | NS   | ns1.example.io                                                      | 3600 |    0 |        NULL |        0 | NULL      |    1 |
|        3 |         1 | example.io     | NS   | ns2.example.io                                                      | 3600 |    0 |        NULL |        0 | NULL      |    1 |
| 17579664 |         1 | ns1.example.io | A    | x.x.x.1                                                             | 3600 |    0 |        NULL |        0 | NULL      |    1 |
| 17579666 |         1 | ns2.example.io | A    | x.x.x.2                                                             | 3600 |    0 |        NULL |        0 | NULL      |    1 |
| 17579675 |         1 | example.io     | SOA  | ns1.example.io support.example.io 2020029263 10800 3600 604800 3600 | 3600 |    0 |        NULL |        0 | NULL      |    1 |
+----------+-----------+--------------------+------+-----------------------------------------------------------------+------+------+-------------+----------+-----------+------+

Lastly, here's my build-time plugin.cfg for coredns:

# Directives are registered in the order they should be executed.
#
# Ordering is VERY important. Every plugin will feel the effects of all other
# plugin below (after) them during a request, but they must not care what plugin
# above them are doing.

# How to rebuild with updated plugin configurations: Modify the list below and
# run `go generate && go build`

# The parser takes the input format of:
#
#     <plugin-name>:<package-name>
# Or
#     <plugin-name>:<fully-qualified-package-name>
#
# External plugin example:
#
# log:github.com/coredns/coredns/plugin/log
# Local plugin example:
# log:log

metadata:metadata
cancel:cancel
tls:tls
reload:reload
nsid:nsid
bufsize:bufsize
root:root
bind:bind
debug:debug
trace:trace
ready:ready
health:health
pprof:pprof
prometheus:metrics
errors:errors
log:log
dnstap:dnstap
acl:acl
any:any
chaos:chaos
loadbalance:loadbalance
cache:cache
rewrite:rewrite
dnssec:dnssec
autopath:autopath
template:template
transfer:transfer
hosts:hosts
route53:route53
azure:azure
clouddns:clouddns
federation:github.com/coredns/federation
k8s_external:k8s_external
kubernetes:kubernetes
file:file
auto:auto
secondary:secondary
etcd:etcd
loop:loop
forward:forward
grpc:grpc
erratic:erratic
whoami:whoami
on:github.com/caddyserver/caddy/onevent
sign:sign
pdsql:github.com/wenerme/wps/coredns/plugin/pdsql
pdsql_sqlite:github.com/jinzhu/gorm/dialects/sqlite