Signed-off-by: Mario Kleinsasser <mario.kleinsasser@gmail.com>

Create separate function for zone check

Signed-off-by: Mario Kleinsasser <mario.kleinsasser@gmail.com>

Add tests for zone A records

Signed-off-by: Mario Kleinsasser <mario.kleinsasser@gmail.com>

Remove pointer from checkZoneForRecord func signature, Add documentation

Signed-off-by: Mario Kleinsasser <mario.kleinsasser@gmail.com>

Change apex to zone, Update readme information, Add additional tests

Signed-off-by: Mario Kleinsasser <mario.kleinsasser@gmail.com>

Change zone to apex

Signed-off-by: Mario Kleinsasser <mario.kleinsasser@gmail.com>

Change readme to reflect apex change

Signed-off-by: Mario Kleinsasser <mario.kleinsasser@gmail.com>

Correct code comment

Signed-off-by: Mario Kleinsasser <mario.kleinsasser@gmail.com>

Correct string join for apex.dns

Signed-off-by: Mario Kleinsasser <mario.kleinsasser@gmail.com>
This commit is contained in:
Mario Kleinsasser
2018-04-27 20:36:58 +02:00
committed by Miek Gieben
parent 9d25b6d8b9
commit 13b1f5469a
3 changed files with 134 additions and 3 deletions

View File

@@ -128,6 +128,48 @@ Querying with dig:
reverse.skydns.local.
~~~
### Zone name as A record
The zone name itself can be used A record. This behavior can be achieved by writing special entries to the ETCD path of your zone. If your zone is named `skydns.local` for example, you can create an `A` record for this zone as follows:
~~~
% curl -XPUT http://127.0.0.1:2379/v2/keys/skydns/local/skydns/dns/apex -d value='{"host":"1.1.1.1","ttl":"60"}'
~~~
If you query the zone name itself, you will receive the created `A` record:
~~~ sh
% dig +short skydns.local @localhost
1.1.1.1
~~~
If you would like to use DNS RR for the zone name, you can set the following:
~~~
% curl -XPUT http://127.0.0.1:2379/v2/keys/skydns/local/skydns/dns/apex/x1 -d value='{"host":"1.1.1.1","ttl":"60"}'
% curl -XPUT http://127.0.0.1:2379/v2/keys/skydns/local/skydns/dns/apex/x2 -d value='{"host":"1.1.1.2","ttl":"60"}'
~~~
If you query the zone name now, you will get the following response:
~~~ sh
dig +short skydns.local @localhost
1.1.1.1
1.1.1.2
~~~
If you would like to use `AAAA` records for the zone name too, you can set the following:
~~~
% curl -XPUT http://127.0.0.1:2379/v2/keys/skydns/local/skydns/dns/apex/x3 -d value='{"host":"2003::8:1","ttl":"60"}'
% curl -XPUT http://127.0.0.1:2379/v2/keys/skydns/local/skydns/dns/apex/x4 -d value='{"host":"2003::8:2","ttl":"60"}'
~~~
If you query the zone name now for `AAAA` now, you will get the following response:
~~~ sh
dig +short skydns.local AAAA @localhost
2003::8:1
2003::8:2
~~~
## Bugs
Only the etcdv2 protocol is supported.

View File

@@ -43,6 +43,25 @@ var services = []*msg.Service{
// Nameservers.
{Host: "10.0.0.2", Key: "a.ns.dns.skydns.test."},
{Host: "10.0.0.3", Key: "b.ns.dns.skydns.test."},
// Zone name as A record (basic, return all)
{Host: "10.0.0.2", Key: "x.skydns_zonea.test."},
{Host: "10.0.0.3", Key: "y.skydns_zonea.test."},
// Zone name as A (single entry).
{Host: "10.0.0.2", Key: "x.skydns_zoneb.test."},
{Host: "10.0.0.3", Key: "y.skydns_zoneb.test."},
{Host: "10.0.0.4", Key: "apex.dns.skydns_zoneb.test."},
// A zone record (rr multiple entries).
{Host: "10.0.0.2", Key: "x.skydns_zonec.test."},
{Host: "10.0.0.3", Key: "y.skydns_zonec.test."},
{Host: "10.0.0.4", Key: "a1.apex.dns.skydns_zonec.test."},
{Host: "10.0.0.5", Key: "a2.apex.dns.skydns_zonec.test."},
// AAAA zone record (rr multiple entries mixed with A).
{Host: "10.0.0.2", Key: "x.skydns_zoned.test."},
{Host: "10.0.0.3", Key: "y.skydns_zoned.test."},
{Host: "10.0.0.4", Key: "a1.apex.dns.skydns_zoned.test."},
{Host: "10.0.0.5", Key: "a2.apex.dns.skydns_zoned.test."},
{Host: "2003::8:1", Key: "a3.apex.dns.skydns_zoned.test."},
{Host: "2003::8:2", Key: "a4.apex.dns.skydns_zoned.test."},
// Reverse.
{Host: "reverse.example.com", Key: "1.0.0.10.in-addr.arpa."}, // 10.0.0.1
}
@@ -214,6 +233,43 @@ var dnsTestCases = []test.Case{
Qname: "skydns_extra.test.", Qtype: dns.TypeSOA,
Answer: []dns.RR{test.SOA("skydns_extra.test. 300 IN SOA ns.dns.skydns_extra.test. hostmaster.skydns_extra.test. 1460498836 14400 3600 604800 60")},
},
// A Record Test for backward compatibility for zone records
{
Qname: "skydns_zonea.test.", Qtype: dns.TypeA,
Answer: []dns.RR{
test.A("skydns_zonea.test. 300 A 10.0.0.2"),
test.A("skydns_zonea.test. 300 A 10.0.0.3"),
},
},
// A Record Test for single A zone record
{
Qname: "skydns_zoneb.test.", Qtype: dns.TypeA,
Answer: []dns.RR{test.A("skydns_zoneb.test. 300 A 10.0.0.4")},
},
// A Record Test for multiple A zone records
{
Qname: "skydns_zonec.test.", Qtype: dns.TypeA,
Answer: []dns.RR{
test.A("skydns_zonec.test. 300 A 10.0.0.4"),
test.A("skydns_zonec.test. 300 A 10.0.0.5"),
},
},
// A Record Test for multiple mixed A and AAAA records
{
Qname: "skydns_zoned.test.", Qtype: dns.TypeA,
Answer: []dns.RR{
test.A("skydns_zoned.test. 300 A 10.0.0.4"),
test.A("skydns_zoned.test. 300 A 10.0.0.5"),
},
},
// AAAA Record Test for multiple mixed A and AAAA records
{
Qname: "skydns_zoned.test.", Qtype: dns.TypeAAAA,
Answer: []dns.RR{
test.AAAA("skydns_zoned.test. 300 AAAA 2003::8:1"),
test.AAAA("skydns_zoned.test. 300 AAAA 2003::8:2"),
},
},
// Reverse lookup
{
Qname: "1.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR,
@@ -233,7 +289,7 @@ func newEtcdPlugin() *Etcd {
Upstream: upstream.Upstream{Forward: &p},
PathPrefix: "skydns",
Ctx: context.Background(),
Zones: []string{"skydns.test.", "skydns_extra.test.", "in-addr.arpa."},
Zones: []string{"skydns.test.", "skydns_extra.test.", "skydns_zonea.test.", "skydns_zoneb.test.", "skydns_zonec.test.", "skydns_zoned.test.", "in-addr.arpa."},
Client: client,
}
}