debian 11搭建主从DNS
环境
NDS主服务器:192.168.1.4
DNS从服务器:192.168.1.5
安装包,主从都安装
apt install -y bind9 dnsutils
配置主服务器
echo "nameserver 192.168.1.4" > /etc/resolv.conf
cd /etc/bind/
vim named.conf.default-zones
添加以下内容
zone "skills.com" {
type master;
allow-update { 192.168.1.5; };
file "/etc/bind/db.zzz";
};
zone "1.168.192.in-addr.arpa" {
type master;
allow-update { 192.168.1.5; };
file "/etc/bind/db.fff";
};
cp db.local db.zzz
cp db.127 db.fff
cat db.zzz
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA skills.com. admin.skills.com. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS skills.com.
@ IN A 127.0.0.1
@ IN AAAA ::1
ftp IN A 192.168.1.4
www IN A 192.168.1.5
cat db.fff
;
; BIND reverse data file for local loopback interface
;
$TTL 604800
@ IN SOA skills.com. admin.skills.com. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS skills.com.
4 IN PTR ftp.skills.com.
5 IN PTR www.skills.com.
systemctl restart named.service
nslookup
> www.skills.com
Server: 192.168.1.4
Address: 192.168.1.4
Name: www.skills.com
Address: 192.168.1.5
> ftp.skills.com
Server: 192.168.1.4
Address: 192.168.1.4
Name: ftp.skills.com
Address: 192.168.1.4
> 192.168.1.4
4.1.168.192.in-addr.arpa name = ftp.skills.com.
> 192.168.1.5
5.1.168.192.in-addr.arpa name = www.skills.com.
> exit
配置从服务器
echo "nameserver 192.168.1.5" > /etc/resolv.conf
vim named.conf.default-zones
添加以下内容
zone "skills.com" {
type slave;
masters { 192.168.1.4; };
file "/etc/bind/db.zzz";
};
zone "1.168.192.in-addr.arpa" {
type slave;
masters { 192.168.1.4; };
file "/etc/bind/db.fff";
};
systemctl restart named.service
nslookup
> www.skills.com
Server: 192.168.1.5
Address: 192.168.1.5
Name: www.skills.com
Address: 192.168.1.5
> ftp.skills.com
Server: 192.168.1.5
Address: 192.168.1.5
Name: ftp.skills.com
Address: 192.168.1.4
> 192.168.1.4
4.1.168.192.in-addr.arpa name = ftp.skills.com.
> 192.168.1.5
5.1.168.192.in-addr.arpa name = www.skills.com.
> exit