Debian配置主从DNS服务器
Bind是使用最广泛的DomainName Server
- DNS主服务器:
192.168.5.8
- DNS辅服务器:
192.168.4.9
主服务安装软件
apt-get install bind9
修改/etc/bind/named.conf.local
添加正向解析文件
zone "hlooc.cn" {
type master;
file "/etc/bind/hlooc.cn.hosts";
masterfile-format text;
allow-update {192.168.4.9;};//从服务器ip
};
新增数据文件cp db.local hlooc.cn.hosts
添加如下记录
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA localhost. root.localhost. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS localhost.
@ IN A 127.0.0.1
@ IN AAAA ::1
omv IN A 192.168.4.10
修改/etc/bind/named.conf.options
forwarders {
222.246.129.80;//公共DNS
114.114.114.114;//公共DNS
};
重启服务
rndc reload
从服务安装软件与主服务一致
修改/etc/bind/named.conf.local
zone "hlooc.cn" {
type slave;
masters {192.168.5.8;};
file "/etc/bind/slaves/hlooc.cn.hosts";
masterfile-format text;
};
修改/etc/bind/named.conf.options
与主服务器一致
重启服务
rndc reload
验证测试dig ovm.hlooc.cn
; <<>> DiG 9.11.5-P4-5.1+deb10u3-Debian <<>> omv.hlooc.cn
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2747
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 1f1078811a0d27da40f576216034a26042f4e7b1290819a4 (good)
;; QUESTION SECTION:
;omv.hlooc.cn. IN A
;; ANSWER SECTION:
omv.hlooc.cn. 604800 IN A 192.168.4.10
;; AUTHORITY SECTION:
hlooc.cn. 604800 IN NS localhost.
;; ADDITIONAL SECTION:
localhost. 604800 IN A 127.0.0.1
localhost. 604800 IN AAAA ::1
;; Query time: 0 msec
;; SERVER: 192.168.4.9#53(192.168.4.9)
;; WHEN: Tue Feb 23 14:36:16 CST 2021
;; MSG SIZE rcvd: 155