2.CentOS6.5下的DNS主从区域传送配置

接着《1.CentOS6.5下的基础DNS配置》来说,主从区域传送只能让从服务器来进行传送,不给任何人传送,我们看看上一章节《1.CentOS6.5下的基础DNS配置》是否可传送:

[root@localhost etc]# dig -t axfr itox.com.cn @192.168.100.3
;; Connection to 192.168.100.3#53(192.168.100.3) for itox.com.cn failed: host unreachable.
[root@localhost etc]# dig -t axfr itox.com.cn @192.168.100.3

; <<>> DiG 9.9.4-RedHat-9.9.4-73.el7_6 <<>> -t axfr itox.com.cn @192.168.100.3
;; global options: +cmd
itox.com.cn. 600 IN SOA ns1.itox.com.cn. admin.itox.com.cn. 2019040701 7200 540 259200 36000
itox.com.cn. 600 IN NS ns1.itox.com.cn.
itox.com.cn. 600 IN MX 10 mail.itox.com.cn.
*.itox.com.cn. 600 IN A 192.168.100.3
ftp.itox.com.cn. 600 IN A 192.168.100.25
kali2.itox.com.cn. 600 IN A 192.168.100.22
kali3.itox.com.cn. 600 IN A 192.168.100.23
mail.itox.com.cn. 600 IN A 192.168.100.24
nfs.itox.com.cn. 600 IN A 192.168.100.28
ns1.itox.com.cn. 600 IN A 192.168.100.3
radius.itox.com.cn. 600 IN CNAME ftp.itox.com.cn.
samba.itox.com.cn. 600 IN A 192.168.100.27
www.itox.com.cn. 600 IN A 192.168.100.26
itox.com.cn. 600 IN SOA ns1.itox.com.cn. admin.itox.com.cn. 2019040701 7200 540 259200 36000
;; Query time: 2 msec
;; SERVER: 192.168.100.3#53(192.168.100.3)
;; WHEN: 日 4月 07 22:25:18 CST 2019
;; XFR size: 14 records (messages 1, bytes 343)

这里我们看到是能够被任何人传送的,因此我们在配置DNS主从传送的时候还需要改动一下named.conf只能被从服务器(这里实验指定192.168.100.24为从服务器),开始配置之前,主从服务器都改一下/etc/sysconfig/named文件,默认里面全部是注释的,加一行在末尾:OPTIONS="-4",去除去IPv6的解析,只解析IPv4,OPTIONS选项的值可以是:whatever、-4、-6中的一个,不然在主从传送过程中会看到一堆的:named network unreachable resolving,主从都要改,记得!

区域传送DNS主服务器named.conf如下,有改动的位置专注标红

options {
directory "/var/named";
#recursion yes;
allow-recursion { 192.168.100.0/24; };  #这里只允许给192.168.100.0/24的网段递归查询,实际中几乎不会用
};

zone "." IN {
type hint;
file "named.ca";
};

zone "localhost" IN {
type master;
file "named.localhost";
allow-transfer { none; };
};

zone "0.0.127" IN {
type master;
file "named.loopback";
allow-transfer { none; };
};

zone "itox.com.cn" IN {
type master;
file "itox.com.cn.zone";
allow-transfer { 192.168.100.24; };
};

zone "100.168.192.in-addr.arpa" IN {
type master;
file "192.168.100.zone";
allow-transfer { 192.168.100.24; };
};

把主服务器的named.conf复制到从服务器相同的位置,然后改动部分内容,就可以启动服务了,从服务器named.conf如下:

options {
directory "/var/named";
#recursion yes;
allow-recursion { 192.168.100.0/24; };
};

zone "." IN {
type hint;
file "named.ca";
};

zone "localhost" IN {
type master;
file "named.localhost";
allow-transfer { none; };
};

zone "0.0.127" IN {
type master;
file "named.loopback";
allow-transfer { none; };
};

zone "itox.com.cn" IN {
type slave;      #这里改成从哦
file "slaves/itox.com.cn.zone";    #传送过来的文件放在slaves目录下,这个文件夹named用户是用权限写入的
masters { 192.168.100.3; };       #指定主服务器在哪里
masterfile-format text;   #这个写上,不然你看到的主服务器传送过来的/var/named/slaves/itox.com.cn的正反向文件是乱码,raw格式的,无法读。
allow-transfer { none; };  #我就是从了,我就不给别人传送了
};

zone "100.168.192.in-addr.arpa" IN {
type slave;
file "slaves/192.168.100.zone";
masterfile-format text;
masters { 192.168.100.3; };
allow-transfer { none; };
};

 

好了,配置完成,验证办法很简单,直接看看/var/named/slaves目录下,文件过来了没有。

转载于:https://www.cnblogs.com/boltkiller/p/10667987.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是CentOS 7搭建主从DNS服务器的步骤: 1.安装bind软件包 ```shell yum install bind bind-utils -y ``` 2.配置DNS服务器 编辑主DNS服务器的配置文件`/etc/named.conf`,添加以下内容: ```shell zone "example.com" IN { type master; file "example.com.zone"; allow-update { none; }; }; ``` 其中`example.com`为你的域名,`example.com.zone`为你的域名解析文件。 创建域名解析文件`/var/named/example.com.zone`,添加以下内容: ```shell $TTL 1D @ IN SOA ns1.example.com. root.example.com. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum IN NS ns1.example.com. IN MX 10 mail.example.com. ns1 IN A 192.168.0.1 mail IN A 192.168.0.2 www IN A 192.168.0.3 ``` 其中`ns1.example.com.`为主DNS服务器的域名,`root.example.com.`为管理员邮箱,`ns1`、`mail`、`www`为主DNS服务器解析的主机名,`A`为主机名对应的IP地址。 启动并设置bind服务开机自启动: ```shell systemctl start named systemctl enable named ``` 3.配置DNS服务器 编辑从DNS服务器的配置文件`/etc/named.conf`,添加以下内容: ```shell zone "example.com" IN { type slave; file "slaves/example.com.zone"; masters { 192.168.0.1; }; }; ``` 其中`example.com`为你的域名,`slaves/example.com.zone`为你的域名解析文件的存放路径,`192.168.0.1`为主DNS服务器的IP地址。 启动并设置bind服务开机自启动: ```shell systemctl start named systemctl enable named ``` 4.测试DNS解析 修改客户端的DNS配置文件`/etc/resolv.conf`,添加以下内容: ```shell search example.com nameserver 192.168.0.1 nameserver 192.168.0.2 ``` 其中`example.com`为你的域名,`192.168.0.1`为主DNS服务器的IP地址,`192.168.0.2`为从DNS服务器的IP地址。 使用`ping`命令测试DNS解析是否正常: ```shell ping www.example.com ``` 如果能够ping通,则说明DNS解析正常。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值