描述
redis 啟用從 redis 資料庫讀取網域資料。此外掛程式應位於 plugins.cfg 中 etcd 的旁邊。
語法
redis
redis 從 redis 伺服器載入權威網域
address 預設為本機 redis 伺服器 (localhost:6379)
redis {
address ADDR
password PWD
prefix PREFIX
suffix SUFFIX
connect_timeout TIMEOUT
read_timeout TIMEOUT
ttl TTL
}
address
是要連線的 redis 伺服器位址,格式為 host:port 或 ip:port。password
是 redis 伺服器的 auth 金鑰connect_timeout
連線到 redis 伺服器時的等待時間,以毫秒為單位read_timeout
等待 redis 伺服器回應的時間,以毫秒為單位ttl
DNS 記錄的預設 ttl,如果未提供則為 300prefix
將 PREFIX 加入所有 redis 金鑰suffix
將 SUFFIX 加入所有 redis 金鑰
範例
. {
redis example.com {
address localhost:6379
password foobared
connect_timeout 100
read_timeout 100
ttl 360
prefix _dns:
}
}
反向網域
目前尚不支援反向網域。
Proxy
目前尚不支援 Proxy。
redis 資料庫中的網域格式
網域
每個網域都以雜湊對應表的形式儲存在 redis 中,zone 作為金鑰
redis-cli>KEYS *
1) "example.com."
2) "example.net."
redis-cli>
DNS RR
dns RR 以 json 字串的形式儲存在 redis 中,使用位址作為欄位金鑰。 @ 用於網域自己的 RR 值。
A
{
"a":{
"ip4" : "1.2.3.4",
"ttl" : 360
}
}
AAAA
{
"aaaa":{
"ip6" : "::1",
"ttl" : 360
}
}
CNAME
{
"cname":{
"host" : "x.example.com.",
"ttl" : 360
}
}
TXT
{
"txt":{
"text" : "this is a text",
"ttl" : 360
}
}
NS
{
"ns":{
"host" : "ns1.example.com.",
"ttl" : 360
}
}
MX
{
"mx":{
"host" : "mx1.example.com",
"priority" : 10,
"ttl" : 360
}
}
SRV
{
"srv":{
"host" : "sip.example.com.",
"port" : 555,
"priority" : 10,
"weight" : 100,
"ttl" : 360
}
}
SOA
{
"soa":{
"ttl" : 100,
"mbox" : "hostmaster.example.com.",
"ns" : "ns1.example.com.",
"refresh" : 44,
"retry" : 55,
"expire" : 66
}
}
範例
$ORIGIN example.net.
example.net. 300 IN SOA <SOA RDATA>
example.net. 300 NS ns1.example.net.
example.net. 300 NS ns2.example.net.
*.example.net. 300 TXT "this is a wildcard"
*.example.net. 300 MX 10 host1.example.net.
sub.*.example.net. 300 TXT "this is not a wildcard"
host1.example.net. 300 A 5.5.5.5
_ssh.tcp.host1.example.net. 300 SRV <SRV RDATA>
_ssh.tcp.host2.example.net. 300 SRV <SRV RDATA>
subdel.example.net. 300 NS ns1.subdel.example.net.
subdel.example.net. 300 NS ns2.subdel.example.net.
上述網域資料應在 redis 中儲存如下
redis-cli> hgetall example.net.
1) "_ssh._tcp.host1"
2) "{\"srv\":[{\"ttl\":300, \"target\":\"tcp.example.com.\",\"port\":123,\"priority\":10,\"weight\":100}]}"
3) "*"
4) "{\"txt\":[{\"ttl\":300, \"text\":\"this is a wildcard\"}],\"mx\":[{\"ttl\":300, \"host\":\"host1.example.net.\",\"preference\": 10}]}"
5) "host1"
6) "{\"a\":[{\"ttl\":300, \"ip\":\"5.5.5.5\"}]}"
7) "sub.*"
8) "{\"txt\":[{\"ttl\":300, \"text\":\"this is not a wildcard\"}]}"
9) "_ssh._tcp.host2"
10) "{\"srv\":[{\"ttl\":300, \"target\":\"tcp.example.com.\",\"port\":123,\"priority\":10,\"weight\":100}]}"
11) "subdel"
12) "{\"ns\":[{\"ttl\":300, \"host\":\"ns1.subdel.example.net.\"},{\"ttl\":300, \"host\":\"ns2.subdel.example.net.\"}]}"
13) "@"
14) "{\"soa\":{\"ttl\":300, \"minttl\":100, \"mbox\":\"hostmaster.example.net.\",\"ns\":\"ns1.example.net.\",\"refresh\":44,\"retry\":55,\"expire\":66},\"ns\":[{\"ttl\":300, \"host\":\"ns1.example.net.\"},{\"ttl\":300, \"host\":\"ns2.example.net.\"}]}"
redis-cli>