SkyDNS in CoreDNS

March 24, 2016

dns

The etcd middleware is shaping up nicely. With the following Corefile you already have a big chunk of the SkyDNS funcionality:

.:1053 {
    errors
    etcd skydns.local
    proxy . 8.8.8.8:53
}

Which says, run on port 1053, accept queries for all zones, if the zone matches skydns.local. go look in etcd, if it doesn’t forward to GOOG. Multiple zones should work as well, but this is not tested as of yet.

Let’s test this with the examples from SkyDNS’ README. Let’s add all the rails production sites. (Why does this use rails btw?)

Checking with:

dig -p 1053 @localhost SRV 1.rails.production.east.skydns.local

;; QUESTION SECTION:
;1.rails.production.east.skydns.local. IN SRV

;; ANSWER SECTION:
1.rails.production.east.skydns.local. 300 IN SRV 10 100 8080 service1.example.com.

Yeah! It actually works :-)

Wildcards

Lets try the wildcard stuff:

dig -p 1035 @localhost SRV east.skydns.local

;; ANSWER SECTION:
east.skydns.local.      300    IN      SRV     10 20 8080 service1.example.com.
east.skydns.local.      300    IN      SRV     10 20 8080 4.rails.staging.east.skydns.local.
east.skydns.local.      300    IN      SRV     10 20 8080 6.rails.staging.east.skydns.local.

;; ADDITIONAL SECTION:
4.rails.staging.east.skydns.local. 300 IN A    10.0.1.125
6.rails.staging.east.skydns.local. 300 IN AAAA 2003::8:1

Working :) Only change I made was that the TTL is now 300s (might make that a config thing as well).

Remote lookups for resolving names found in etcd are using the proxy middleware, so there is no code duplication there.

Proxy

Records that don’t match the zone(s) are proxied (this needs some few extra features, but is already working pretty well):

% dig -p 1053 @localhost A miek.nl

;; ANSWER SECTION:
miek.nl.		1799	IN	A	139.162.196.78

What you except, an answer from 8.8.8.8.

“Loadbalancing”

If you need A/AAAA shuffling, also know as loadbalancing, add the loadbalance middleware, again, this is just another middleware. From the SkyDNS README:

dig -p 1053 @localhost A db.skydns.local

returns:

db.skydns.local.	300	IN	A	127.0.0.1
db.skydns.local.	300	IN	A	127.0.0.2
db.skydns.local.	300	IN	A	127.0.0.3

In that order, always, Lets add loadbalance middleware to our Corefile, and try again:

.:1053 {
    errors stderr
    loadbalance
    etcd skydns.local
    proxy . 8.8.8.8:53
}

Whee randomized answer:

; ANSWER SECTION:
db.skydns.local.	300	IN	A	127.0.0.1
db.skydns.local.	300	IN	A	127.0.0.3
db.skydns.local.	300	IN	A	127.0.0.2

As said some features need to be added, mostly dealing with UDP buffer sizing, more tests (as always) and the “advanced” features like Groups and TargetStrip need to be ported and tested.

SkyDNS  CoreDNS  Middleware  Progress  DNS