正向记录 为 AAAA
反向记录 为 PTR 跟 ipv4 一样,但格式为 ip6.arpa格式
举个例子 创建随机 ipv6 ula地址
echo fd`openssl rand -hex 15|sed 's/\(..\)/&/g;s/:$//'` |awk 'BEGIN{FS=""}{for(i=1;i<=NF;i++){if(i%4==0&&i!=NF){printf $i":"}else{printf $i}}print ""}'
输出
fd35:0f63:919f:db4a:9ed9:59c3:d9d7:88cf
域名 aaa.test.com
acl OKHOSTS {localhost;localnets;fc00::/6;::1;};
正向解析 zone
zone “test.com” {
type master;
file “/etc/bind/test.com.zone”;
allow-query {
OKHOSTS;
};
allow-transfer {
OKHOSTS;
#none;
};
allow-update {
none;
};
};
在 /etc/bind/test.com.zone 文件 配置
$ORIGIN .
$TTL 86400 ; 1 day
test.com IN SOA test.com. root.test.com. (
2021112017 ; serial
86400 ; refresh (1 day)
3600 ; retry (1 hour)
604800 ; expire (1 week)
10800 ; minimum (3 hours)
)
NS root.test.com.
$TTL 3600
; 定义 aaa.test.com的AAAA记录
aaa AAAA fd35:0f63:919f:db4a:9ed9:59c3:d9d7:88cf
反向解析zone
需要 ip6.arpa格式
安装软件 ipv6calc
获取 ula前缀的 ip6.arpa格式
ipv6calc -aq fd35:0f63:919f:db4a:9ed9:59c3:d9d7:88cf|cut -c 33-63
得到 ula前缀
a.4.b.d.f.9.1.9.3.6.f.0.5.3.d.f
定义 反向解析zone
zone “a.4.b.d.f.9.1.9.3.6.f.0.5.3.d.f.ip6.arpa” {
type master;
file “/etc/bind/rev.test.com.zone”;
allow-update {none;};
allow-transfer {
OKHOSTS;
#none;
};
allow-query {OKHOSTS;};
};
获取 aaa.test.com ipv6的主机id
ipv6calc -aq fd35:0f63:919f:db4a:9ed9:59c3:d9d7:88cf|cut -c 1-31
得到
f.c.8.8.7.d.9.d.3.c.9.5.9.d.e.9
在 /etc/bind/rev.test.com.zone 配置反向ipv6记录
$ORIGIN .
$TTL 86400 ; 1 day
a.4.b.d.f.9.1.9.3.6.f.0.5.3.d.f.ip6.arpa IN SOA test.com. root.test.com. (
2021112017 ; serial
86400 ; refresh (1 day)
3600 ; retry (1 hour)
604800 ; expire (1 week)
10800 ; minimum (3 hours)
)
NS root.test.com.
$ORIGIN a.4.b.d.f.9.1.9.3.6.f.0.5.3.d.f.ip6.arpa.
#定义 aaa.test.com ipv6 ptr
f.c.8.8.7.d.9.d.3.c.9.5.9.d.e.9 PTR aaa.test.com.