First Light

March 14, 2016

dns

So I did fork Caddy, and converted it into something that almost resembles a DNS server.

This is Caddy DNS (need an name!) without any configuration, i.e. an empty Caddyfile. It will then fallback and be a reflection server (couldn’t think of something better…). It will respond to queries that ask for who.<name> and will respond with your IP, port and transport.

So the first light query and answer would be:

dig @localhost -p 1053 A who.miek.nl

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62561
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;who.miek.nl.			IN	A

;; ANSWER SECTION:
who.miek.nl.		0	IN	AAAA	::1

;; ADDITIONAL SECTION:
who.miek.nl.		0	IN	TXT	"Port: 1234 (udp)"

And slightly later with the port number properly fixed:

% dig @localhost -p 1053 A who.blaa.nl +tcp -4

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23218
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;who.blaa.nl.			IN	A

;; ANSWER SECTION:
who.blaa.nl.		0	IN	A	127.0.0.1

;; ADDITIONAL SECTION:
who.blaa.nl.		0	IN	TXT	"Port: 47293 (tcp)"

After some coding and “implementing”1 DNS Zones (it’s in middleware/file) a current startup with the following Caddyfile looks like this:

miek.nl {
    file db.miek.nl
}

bla.miek.nl dns.miek.nl {
    file db.dns.miek.nl
}
% ./daddy
Activating privacy features...conf hosts miek.nl
conf hosts bla.miek.nl
conf hosts dns.miek.nl
FILE MIDDLEWARE

The FILE MIDDLEWARE is a sign that querying miek.nl actually hits the file middleware. Note that querying anything else still falls back to the (default) reflection middleware - need to fix that. Speaking of which this is the current TODO list:

  • Zone parsing (better zone impl.)
  • zones can port numbers after them (miek.nl:1234), should be stripped
  • caddy is always a reflection server, it should not be
  • A Caddyfile with just a host, should be a reflection server for that host only, right now it’s for “.”
  • DNSSEC middleware
  • Cleanup middlewares:
    • Fix rewrite to be useful
    • Monitoring middleware
    • ANY to HINFO rewrite example (and make the thing work)
  • Fix graceful restart
  • Fix file middleware to use a proper zone implementation
  • Fix/Add DNS response recorder
  • There is no scheme for DNS - remove it from everywhere
  • TESTS; don’t compile, need cleanups

  1. Horrible implementation! [return]
DNS  Caddy  Server  Porting  core  coreDNS