vim /etc/name.conf
options {
directory "/var/named";
recursion yes;#定义开启递归功能;默认是给所有用户递归。
allow-recursion { 172.16.0.0/16;}; #表示只对这个网段的用户递归;或者定义递归客户端来源的;
allow-query #定义谁可以来进行查询;
};
zone "." IN {
type hint;
file "named.ca";
allow-transfer { none; };
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-transfer { none; };#表示localhost这个区域谁都不允许传送;
};
zone "zledu.com" IN {
type master;
file "zledu.com.zone";
allow-transfer { 172.16.100.2; };#表示zledu.com这个区域只允许172.16.100.2这台主机进行传送。
};
dig +recurse -t A www.sohu.com @172.16.100.1
dig +norecurse -t A www.sohu.com @172.16.100.1
dig -trace -t A www.baidu.com @172.16.100.1 #显示整个过程。
dig -t axfr zledu.com
axfs:完全区域传送;
ixfs:增量区域传送
区域传送:(只能允许自己的从服务器进行数据传送,如何定义有哪些主机进行传送)
主、从。
如何建立DNS的从服务器?
rpm -e bind-libs bind-utils
scp 172.16.100.1:/etc/yum.repos.d/server.repo ./
yum -y install bind97 bind97-utils
ls -l /var/named/#注意同步数据的时候是以named用户,named组来同步数据的;因此直接放在这个目录下面是不可以的;
同步过来的时候,直接放在slave目录下即可;有两种方案;
[[email protected] ~]# setenforce 0
setenforce: SELinux is disabled
[[email protected] etc]# mv named.conf /etc/named.conf.org
[[email protected] etc]# scp 172.16.100.1:/etc/named.conf /etc/
vim name.conf
zone "zledu.com" IN {
masters { 172.16.100.1; };
type slave;
file "slaves/zledu.com.zone";
allow-transfer { none; };
};
zone "100.16.172.in-addr.arpa" IN {
type slave;
file "slaves/172.16.100.zone";
masters { 172.16.100.1; };
allow-transfer { none; };
};
[[email protected] ~]# cat /var/named/zledu.com.zone
$TTL 600
zledu.com. IN SOA ns1.zledu.com. admin.zledu.com. (
20150523
1H
5M
2D
6H )
IN NS ns1
IN NS ns2
IN MX 10 mail
ns1 IN A 172.16.100.1
ns2 IN A 172.16.100.2
mail IN A 172.16.100.2
pop IN A 172.16.100.4
www IN A 172.16.100.1
www IN A 172.16.100.3
DNS的日志文件路径/var/log/messages:
[[email protected] etc]# service named start
[[email protected] etc]# tail /var/log/messages
在同步的时候,可能会出现错误,需要将我们的NS记录再增加一条即可;当我们新增加一条ns服务器的时候,一定要加一条记录。
rndc: 远程管理dns服务器用的;
-h查看帮助信息;
rndc-confgen >/etc/rndc.conf
[[email protected] ~]# cat /etc/rndc.conf
# Start of rndc.conf
key "rndc-key" {
algorithm hmac-md5;
secret "GluqNmX4q97sW1a55ZUhqw==";
};
options {
default-key "rndc-key";
default-server 127.0.0.1;
default-port 953;
};
# End of rndc.conf
# Use with the following in named.conf, adjusting the allow list as needed:
# key "rndc-key" {
# algorithm hmac-md5;
# secret "GluqNmX4q97sW1a55ZUhqw==";
# };
#
# controls {
# inet 127.0.0.1 port 953
# allow { 127.0.0.1; } keys { "rndc-key"; };
# };
# End of named.conf
将其追加到/etc/name.conf里面;
rndc -c /etc/rndc.conf #默认就能控制服务器了;
[[email protected] ~]# service named reload
Reloading named: [ OK ]
[[email protected] ~]# rndc -c /etc/rndc.conf status
我们当前的主机能否控制远端主机,需要修改named.conf里面的配置文件;
cat /etc/named.conf
controls {
inet 127.0.0.1 port 953 #表示监听主机的端口;
allow { 127.0.0.1; } keys { "rndc-key"; };#表示允许那台主机来控制;
};
controls {
inet 172.16.100.1 port 953
allow { 172.16.100.2; } keys { "rndc-key"; };
};
接着执行如下操作即可;
scp /etc/rndc.conf 172.16.100.2:/root
再在172.16.100.2上进行相应的修改;
[[email protected] slaves]# cat /root/rndc.conf
# Start of rndc.conf
key "rndc-key" {
algorithm hmac-md5;
secret "GluqNmX4q97sW1a55ZUhqw==";
};
options {
default-key "rndc-key";
default-server 172.16.100.1;
default-port 953;
};
[[email protected] slaves]# rndc -c /root/rndc.conf status
注意在本机上进行控制很常用,允许远程主机用的话,还是很少见的,所以我们至少要在本机上生成一个配置文件。