环境同DNS练习之正向解析。
在sishen64主机上安装必要软件
[[email protected] ~]# yum install -y bind bind-chroot bind-libs bind-utils
重启named服务
编辑核心配置文件:
[[email protected] ~]# vim /var/named/chroot/etc/named.conf
重启named服务:
[[email protected] ~]# service named restart
查看:
[[email protected] ~]# dig @localhost dns.sishen63.cn
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> @localhost dns.sishen63.cn
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 31979
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;dns.sishen63.cn. IN A
;; Query time: 4025 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sat Jan 20 15:29:35 2018
;; MSG SIZE rcvd: 33
转发到sishen63上解析成功!
配置DNS主从:
环境仍然是在DNS练习之正向解析下进行的。
在sishen63上:(改为如下内容)
[[email protected] ~]# vim /var/named/chroot/etc/named.rfc1912.zones
,核心配置文件不需要更改。
然后重启named服务。
在sishen64上:
[[email protected] ~]# vim /var/named/chroot/etc/named.conf
[[email protected] ~]# vim /var/named/chroot/etc/named.rfc1912.zones
改为如下内容:
然后重启named服务后,slaves目录及sishen63.cn.zone.slave文件会自动生成,
查看sishen63.cn.zone.slave内容:
[[email protected] ~]# vim /var/named/chroot/var/named/slaves/sishen63.cn.zone.slave
$ORIGIN .
$TTL 86400 ; 1 day
sishen63.cn IN SOA dns.sishen63.cn. root.sish
en63.cn. (
0 ; serial
86400 ; refresh (1 da
y)
3600 ; retry (1 hour
)
604800 ; expire (1 wee
k)
10800 ; minimum (3 ho
urs)
)
NS dns.sishen63.cn.
$ORIGIN sishen63.cn.
dns A 192.168.1.63
ftp A 192.168.1.64
www1 CNAME ftp
内容同sishen63上的sishen63.cn.zone文件一样。
测试并查看结果:
[[email protected] ~]# dig @localhost ftp.sishen63.cn
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> @localhost ftp.sishen63.cn
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39231
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;ftp.sishen63.cn. IN A
;; ANSWER SECTION:
ftp.sishen63.cn. 86400 IN A 192.168.1.64
;; AUTHORITY SECTION:
sishen63.cn. 86400 IN NS dns.sishen63.cn.
;; ADDITIONAL SECTION:
dns.sishen63.cn. 86400 IN A 192.168.1.63
;; Query time: 1 msec
;; SERVER: ::1#53(::1)
;; WHEN: Sat Jan 20 15:47:01 2018
;; MSG SIZE rcvd: 83
解析成功!
配置DNS加密认证
前提是要求主机之间的时间要一直,可以使用ntp来同步时间。
配置核心配置文件支持密钥认证
启用密钥认证,取消这三行注释
添加这些内容:
编辑named.rfc1912.zones 文件,将之前的IP段改为key dnsseckey.
[[email protected] chroot]# vim etc/named.rfc1912.zones
重启named服务:
到此,主节点配置完成。
配置从节点(sishen64):
配置核心配置文件named.conf
[[email protected] ~]# vim /var/named/chroot/etc/named.conf
取消之前注释的三行
同时添加如下内容:
[[email protected] ~]# vim /var/named/chroot/etc/named.rfc1912.zones
改为如下内容:
然后保存,重启named服务。
[[email protected] ~]# dig @localhost ftp.sishen63.cn
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> @localhost ftp.sishen63.cn
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2722
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;ftp.sishen63.cn. IN A
;; ANSWER SECTION:
ftp.sishen63.cn. 86400 IN A 192.168.1.64
;; AUTHORITY SECTION:
sishen63.cn. 86400 IN NS dns.sishen63.cn.
;; ADDITIONAL SECTION:
dns.sishen63.cn. 86400 IN A 192.168.1.63
;; Query time: 26 msec
;; SERVER: ::1#53(::1)
;; WHEN: Sat Jan 20 16:40:02 2018
;; MSG SIZE rcvd: 83
OK,解析成功~
DNS做负载均衡:
[[email protected] ~]# vim /var/named/sishen63.cn.zone
例如:
重启named服务测试:
[[email protected] named]# ping www.sishen63.cn -c 1
PING www.sishen63.cn (192.168.1.164) 56(84) bytes of data.
From 192.168.1.63 icmp_seq=1 Destination Host Unreachable
--- www.sishen63.cn ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 3001ms
[[email protected] named]# ping www.sishen63.cn -c 1
PING www.sishen63.cn (192.168.1.165) 56(84) bytes of data.
From 192.168.1.63 icmp_seq=1 Destination Host Unreachable
--- www.sishen63.cn ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 3001ms
可以发现每次的IP都不一样。
原文地址:https://www.cnblogs.com/zd520pyx1314/p/8321212.html