主从dns服务器上都要:
关闭防火墙:
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
挂载和下载bind
[root@localhost ~]# mount /dev/sr0 /mnt
[root@localhost ~]# dnf install bind -y
主服务器配置:
[root@localhost ~]# vim /etc/named.conf
options {
listen-on port 53 { 192.168.115.100; };//把IP改为自己的IP
directory "/var/named";
allow-query { any; }; //允许那些主机向我发起查询,any(所以主机)
allow-transfer { 192.168.115.133; }; //允许共享资源文件
};
zone "openlab.com" IN {
type master;
file "named.openlab.com";
};
zone "115.168.192.in-addr.arpa" IN {
type master;
file "named.192";
allow-update { none; };
};
[root@localhost ~]# vim /var/named/named.openlab.com
$TTL 1D
@ IN SOA @ 15380914067.163.com (
2024103001
1M
2M
5M
1M
)
IN NS ns.openlab.com.
ns IN A 192.168.115.100
www IN A 192.168.115.133
wwww IN CNAME www
注:如果资源记录文件是通过/var/named/named.localhost模版拷贝修改
方法一:cp -a /var/named/named.localhost /var/named/named.xxxx
方法二:cp /var/named/named.localhost /var/named/named.xxxx
chmod o+r /var/named/named.xxxx
资源记录文件是通过/var/named/named.localhost模版拷贝修改
[root@localhost ~]#cp /var/named/named.localhost /var/named/named.192
[root@localhost ~]#chmod o+r /var/named/named.192//给与写权限
[root@localhost ~]# vim /var/named/named.192
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS ns.openlab.com.
133 PTR www.openlab.com.
100 PTR ns.openlab.com.
[root@localhost ~]# systemctl restart named
从dns服务器(资源文件的备份)
[root@localhost ~]# vim /etc/named.conf
options {
listen-on port 53 { 192.168.115.133; };
directory "/var/named/slaves";
allow-query { any; };
};
zone "openlab.com" IN { //正向解析域
type slave; //slave
file "named.openlab.com"; //正向解析的资源记录文件(数据文件)
masters { 192.168.115.100; };//主dns服务器
};
zone "115.168.192.in-addr.arpa" IN { //网络位地址倒序表示
type slave;
file "named.192";
masters { 192.168.115.100; };
};
[root@localhost ~]# systemctl restart named
[root@localhost ~]# watch ls -l /var/named/slaves/
//查看资源文件传输情况
在客户端进行正反向解析
[root@localhost ~]# nslookup
> server 192.168.115.100
Default server: 192.168.115.100
Address: 192.168.115.100#53
> www.openlab.com
Server: 192.168.115.100
Address: 192.168.115.100#53
Name: www.openlab.com
Address: 192.168.115.133
> 192.168.115.133
133.115.168.192.in-addr.arpa name = www.openlab.com.
>