Skip to content

wenerme/coredns-pdsql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title description weight tags categories date repo home
pdsql
*pdsql* use powerdns generic sql as backend.
10
plugin
pdsql
plugin
external
2017-12-09T10:26:00+08:00

pdsql

pdsql use PowerDNS generic sql as backend.

Use gorm.io/gorm to handle database, support many database as gorm dose.

Syntax

pdsql <dialect> <arg> {
    # enable debug mode
    debug [db]
    # create table for test
    auto-migrate
}

Install Driver

pdsql need db driver for dialect, current gorm do not support auto install driver, the supported driver is bundled with this plugin.

  • sqlite,sqlite3
  • mysql
  • postgres

Examples

Start a server on the 1053 port, use test.db as backend.

test.:1053 {
    pdsql sqlite3 ./test.db {
        debug db
        auto-migrate
    }
}

Prepare data for test.

# Insert records for wener.test
sqlite3 ./test.db 'insert into records(name,type,content,ttl,disabled)values("wener.test","A","192.168.1.1",3600,0)'
sqlite3 ./test.db 'insert into records(name,type,content,ttl,disabled)values("wener.test","TXT","TXT Here",3600,0)'

When queried for "wener.test. A", CoreDNS will respond with:

;; QUESTION SECTION:
;wener.test.			IN	A

;; ANSWER SECTION:
wener.test.		3600	IN	A	192.168.1.1

When queried for "wener.test. ANY", CoreDNS will respond with:

;; QUESTION SECTION:
;wener.test.			IN	ANY

;; ANSWER SECTION:
wener.test.		3600	IN	A	192.168.1.1
wener.test.		3600	IN	TXT	"TXT Here"

Wildcard

# domain id 1
sqlite3 ./test.db 'insert into domains(name,type)values("example.test","NATIVE")'
sqlite3 ./test.db 'insert into records(domain_id,name,type,content,ttl,disabled)values(1,"*.example.test","A","192.168.1.1",3600,0)'

When queried for "first.example.test. A", CoreDNS will respond with:

;; QUESTION SECTION:
;first.example.test.		IN	A

;; ANSWER SECTION:
first.example.test.	3600	IN	A	192.168.1.1

TODO

  • support wildcard record

About

CoreDNS PowerDNS adapter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published