Last active
December 16, 2022 11:25
-
-
Save thesadabc/abdce69f0bb9a9f68b5a97f84cd64020 to your computer and use it in GitHub Desktop.
自建DNS服务器,动态DNS,动态域名解析
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 准备文件夹 | |
mkdir ./primary && chmod 777 ./primary | |
# 创建 tsig key, 后续可以用这个key更新dns, 使用nsupdate,javadns等工具 | |
docker run --rm resystit/bind9:latest tsig-keygen xjpinkey | |
# 启动服务 可能本地53已被系统域名解析占用 | |
docker run --rm -d --name my-dns -p 53:53 -p 53:53/udp \ | |
-v `pwd`/named.conf:/etc/bind/named.conf \ | |
-v `pwd`/primary:/etc/bind/primary \ | |
resystit/bind9:latest named -c /etc/bind/named.conf -g | |
# 更新记录 | |
cat << EOF | nsupdate -d -y "hmac-sha256:xjpinkey:2xxxxxxxxxxxxxxxxxxlANw=" | |
server 127.0.0.1 | |
zone xjp.in. | |
update add test.xjp.in 600 A 8.8.8.8 | |
send | |
EOF | |
#检查结果 | |
dig test.xjp.in @127.0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
key "xjpinkey" { | |
algorithm hmac-sha256; | |
secret "2xxxxxxxxxxxxxxxxxxlANw="; | |
}; | |
options { | |
directory "/var/bind"; | |
allow-transfer {none;}; | |
pid-file "/var/run/named/named.pid"; | |
allow-recursion { none; }; | |
recursion no; | |
}; | |
zone "xjp.in" IN { | |
type primary; | |
allow-update {key xjpinkey;}; | |
file "/etc/bind/primary/xjp.in.text"; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ORIGIN . | |
$TTL 600 | |
xjp.in IN SOA xjp.in. nobody.localhost. ( | |
97 ; serial, 以下参数不知道含义 | |
86400 ; refresh (1 day) | |
43200 ; retry (12 hours) | |
604800 ; expire (1 week) | |
10800 ; minimum (3 hours) | |
) | |
NS xjp.in. | |
A 127.0.0.1 | |
AAAA ::1 | |
$ORIGIN xjp.in. | |
local A 127.0.0.1 ; local.xjp.in to A record 127.0.0.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment