snail2sky / coredns_mysql_extend Goto Github PK
View Code? Open in Web Editor NEWconnect mysql plugin of coredns
License: Apache License 2.0
connect mysql plugin of coredns
License: Apache License 2.0
Hi guys,
I want if the records are not in MySQL return it with the template
module like the config below:
in-addr.arpa.:53 {
log
errors
mysql {
dsn user:pass@tcp(mysql:3306)/coredns
}
template IN PTR in-addr.arpa {
match "^(?P<a>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.](?P<b>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.](?P<c>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.](?P<d>[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]in-addr[.]arpa[.]$"
answer "{{ .Name }} 86400 IN PTR {{ .Group.d }}-{{ .Group.c }}-{{ .Group.b }}-{{ .Group.a }}.static.test.com"
fallthrough
}
}
mysql> select * from zones;
+----+---------------+
| id | zone_name |
+----+---------------+
| 11 | in-addr.arpa. |
+----+---------------+
1 row in set (0.00 sec)
mysql> select * from records;
+----+---------+----------+------+-------------+-----+--------+
| id | zone_id | hostname | type | data | ttl | online |
+----+---------+----------+------+-------------+-----+--------+
| 8 | 11 | 1.1.1.1 | PTR | address.com | 120 | 1 |
+----+---------+----------+------+-------------+-----+--------+
1 row in set (0.00 sec)
mysql>
(.venv) ➜ ansible git:(coredns) ✗ dig @10.1.1.3 -x 1.1.1.1
; <<>> DiG 9.18.18-0ubuntu0.22.04.1-Ubuntu <<>> @10.1.1.3 -x 1.1.1.1
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60231
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: d0ad108a5f6b5713 (echoed)
;; QUESTION SECTION:
;1.1.1.1.in-addr.arpa. IN PTR
;; ANSWER SECTION:
1.1.1.1.in-addr.arpa. 86400 IN PTR 1-1-1-1.static.test.com.
;; Query time: 108 msec
;; SERVER: 10.1.1.3#53(10.1.1.3) (UDP)
;; WHEN: Tue Jan 09 19:42:08 UTC 2024
;; MSG SIZE rcvd: 121
but the problem is template
module responded even if records are on the DB. Anyone with any idea?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.