DNS服务部署
DNS服务部署
1.要求
1.搭建dns服务器能够对自定义的正向或者反向域完成数据解析查询。
2.配置从DNS服务器,对主dns服务器进行数据备份。
2.配置
主服务器:
1.安装BIND
[root@localhost xzy]# sudo dnf install bind bind-utils
2.配置正向区域
[root@localhost xzy]# vim /etc/named.conf
zone "example.com" IN {type master;file "/var/named/example.com.db";allow-transfer { 192.168.194.130; }; # 允许从服务器区域传输
};
[root@localhost xzy]# touch /var/named/example.com.db
[root@localhost xzy]# vim /var/named/example.com.db
$TTL 86400
@ IN SOA ns1.example.com. admin.example.com. (2024110301 ; Serial3600 ; Refresh1800 ; Retry604800 ; Expire86400 ) ; Minimum
;
@ IN NS ns1.example.com.
ns1 IN A 192.168.194.128
www IN A 192.168.194.129
3.配置反向区域
添加反向区域信息
[root@localhost xzy]# vim /etc/named.conf
zone "194.168.192.in-addr.arpa" IN {type master;file "/var/named/192.168.194.db";allow-transfer { 192.168.194.130; }; # 允许从服务器区域传输
};
创建反向区域文件
[root@localhost xzy]# touch /var/named/192.168.194.db
[root@localhost xzy]# vim /var/named/192.168.194.db
$TTL 86400
@ IN SOA ns1.example.com. admin.example.com. (2024110301 ; Serial3600 ; Refresh1800 ; Retry604800 ; Expire86400 ) ; Minimum
;
@ IN NS ns1.example.com.
128 IN PTR ns1.example.com.
129 IN PTR www.example.com.
启动服务
sudo systemctl start named
sudo systemctl enable named
sudo firewall-cmd --add-service=dns --permanent
sudo firewall-cmd --reload
从DNS服务器配置
1.安装BIND
sudo dnf install bind bind-utils
2.配置从区域
在/etc/named.conf中添加配置[root@localhost xzy]# vim /etc/named.conf
zone "example.com" IN {type slave;file "slaves/example.com.db";masters { 192.168.194.128; };
};zone "194.168.192.in-addr.arpa" IN {type slave;file "slaves/192.168.194.db";masters { 192.168.194.128; };
};
启动服务sudo systemctl start named
sudo systemctl enable named
sudo firewall-cmd --add-service=dns --permanent
sudo firewall-cmd --reload
验证
[root@localhost xzy]# dig xzy example.com