linux配置DNS主从服务器
实验设备
主服务器:OpenElur Linux IP地址为192.168.188.129
从服务器:RedHat Linux IP地址为192.168.188.128
实验步骤
1.进行主服务器的基础配置
#安装DNS对应工具
[root@OpenElurRJW ~]# yum install bind -y
#编辑DNS系统配置信息
[root@OpenElurRJW ~]# cat /etc/named.conf
options {
listen-on port 53 { 192.168.188.129; };
directory "/var/named";
allow-query {any;};
allow-transfer {192.168.188.128; };
};
zone "RRR.com" IN {
type master;
file "RRR";
};
zone "188.168.192.in-addr.arpa" IN {
type master;
file "192";
};
2.配置主服务器的解析配置文件
#编辑正向解析配置文件
[root@OpenElurRJW ~]# cat /var/named/RRR
$TTL 1D
@ IN SOA @ admin.RRR.com. ( 2024011700 1D 1H 3H 1D)
IN NS dns.RRR.com.
dns IN A 192.168.188.129
www IN A 192.168.188.129
ftp IN A 192.168.188.129
a IN A 192.168.188.129
aaa IN CNAME a
#编辑反向解析配置文件
[root@OpenElurRJW ~]# cat /var/named/192
$TTL 1D
@ IN SOA @ admin.RRR.com. ( 2024011701 1D 1H 3H 1D )
IN NS dns.RRR.com.
129 IN PTR dns.RRR.com.
129 IN PTR www.RRR.com.
#重启服务
[root@localhost ~]# systemct restart named
3.进行从服务器的基础配置
#安装DNS对应工具
[root@RedHatRJW ~]# yum install bind -y
#编辑DNS系统配置文件
[root@RedHatRJW ~]# cat /etc/named.conf
options {
listen-on port 53 { 192.168.188.129; };
directory "/var/named";
};
zone "RRR.com" IN {
type slave;
file "slaves/named.RRR.com";
masters { 192.168.188.129 ; };
};
zone "188.168.129.in-addr.arpa" IN {
type slave;
file "slaves/named.192.coom";
masters { 192.168.188.129 ;};
};
#重启服务
[root@localhost ~]# systemct restart named
4.实验结果检验
[root@RedHatRJW ~]# nslookup
> server 192.168.188.129
Default server: 192.168.188.129
Address: 192.168.188.129#53
> 192.168.188.129
129.188.168.192.in-addr.arpa name = dns.RRR.com.
129.188.168.192.in-addr.arpa name = www.RRR.com.
> www.RRR.com
Server: 192.168.188.129
Address: 192.168.188.129#53
Name: www.RRR.com
Address: 192.168.188.129