标签:系统 库文件 image 失败 roo blog RoCE ade signed
1基本知识点DNS:Domain Name System 应用层协议
C/S,53/udp, 53/tcp
BIND:Bekerley Internat Name Domain
ISC (www.isc.org)
本地名称解析配置文件:hosts
根域
一级域名:Top Level Domain: tld
com, edu, mil, gov, net, org, int,arpa
三类:组织域、国家域(.cn, .ca, .hk, .tw)、反向域
二级域名
三级域名
最多127级域名
ICANN(The Internet Corporation for Assigned Names and Numbers)
互联网名称与数字地址分配机构,负责在全球范围内对互联网通用顶级域名
(gTLD)以及国家和地区顶级域名(ccTLD)系统的管理、以及根服务器系统
的管理
DNS查询类型:
递归查询
迭代查询
名称服务器:域内负责解析本域内的名称的主机
根服务器:13组服务器
解析类型:
FQDN --> IP
IP --> FQDN
注意:正反向解析是两个不同的名称空间,是两棵不同的解析树DNS服务器类型
DNS服务器的类型:
主DNS服务器
从DNS服务器
缓存DNS服务器(转发器)
- 主DNS服务器:管理和维护所负责解析的域内解析库的服务器
- 从DNS服务器:从主服务器或从服务器“复制”(区域传输)解析库副本
序列号:解析库版本号,主服务器解析库变化时,其序列递增
刷新时间间隔:从服务器从主服务器请求同步解析的时间间隔
重试时间间隔:从服务器请求同步失败时,再次尝试时间间隔
过期时长:从服务器联系不到主服务器时,多久后停止服务- “通知”机制:主服务器解析库发生变化时,会主动通知从服务器
区域解析库:由众多RR组成:
资源记录:Resource Record, RR
记录类型:A, AAAA, PTR, SOA, NS, CNAME, MX
SOA:Start Of Authority,起始授权记录;一个区域解析库有且仅能有一个
SOA记录,必须位于解析库的第一条记录
A:internet Address,作用,FQDN --> IP
AAAA:FQDN --> IPv6
PTR:PoinTeR,IP --> FQDN
NS:Name Server,专用于标明当前区域的DNS服务器
CNAME : Canonical Name,别名记录
MX:Mail eXchanger,邮件交换器
TXT:对域名进行标识和说明的一种方式,一般做验证记录时会使用此项,如:
SPF(反垃圾邮件)记录,https验证等
示例:_dnsauth TXT 2012011200000051qgs69bwoh4h6nht4n1h0lr038x
root:~ # yum install -y bind
root:~ # vim /etc/named.conf
listen-on port 53 { localhost; };
allow-query { any; }
root:/etc/named # systemctl start named.service
vim /etc/named.conf
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
allow-transfer {从服务器IP;}; #只允许从服务器同步
vim /etc/named.rfc1912.zones
添加
zone "qh.com" IN {
type master;
file "qh.com.zone";
}
root:/etc/named # cp -p /var/named/named.localhost /var/named/qh.com.zone
root:/var/named $ vi /var/named/qh.com.zone
$TTL 1D
@ IN SOA master qh.com. (
2019042210 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
master A 192.168.64.151
dbserver1 A 1.1.1.1
dbserver2 A 2.2.2.2
root:~ # systemctl restart named.service #重启服务
root:~ $ dig dbserver1.qh.com @192.168.64.151
yum install bind
vim /etc/named.conf
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
allow-transfer {none;}; #不允许任何机器同步
vim /etc/named.rfc1912.zones
zone "qh.com" {
type slave;
masters {主服务器IP;};
file "slaves/qh.com.slave";
};
root:~ # systemctl start named.service
root:/var/named/slaves # cp -p /var/named/named.localhost /var/named/slave/qh.com.slave
root:/var/named # cd slaves/
root:/var/named/slaves # chmod g+w qh.com.slave
root:/var/named/slaves # rndc reload
server reload successful
root:/var/named/slaves # ll
total 4
-rw-rw---- 1 root named 152 Jun 21 2007 qh.com.slave
root:~ $ vi /etc/sysconfig/network-scripts/ifcfg-ens33
root:~ $ service network restart
Restarting network (via systemctl): [ OK ]
root:~ $ cat /etc/resolv.conf
; generated by /usr/sbin/dhclient-script
search localdomain
nameserver 192.168.64.151
nameserver 192.168.64.152
zone "64.168.192.in-addr.arpa" IN {
type master;
file "192.168.64.zone";
};
root:/var/named $ cp -p qh.com.zone 192.168.64.zone
root:/var/named $ vim 192.168.64.zone
$TTL 1D
@ IN SOA master qh.com. ( 1 1H 10M 12H 1D )
NS master
master A 192.168.64.151
7 PTR websrv.qh.com.
6 PTR websrv.qh.com.
100 PTR mail.qh.com.
root:~ $ rndc reload
root:~ $ systemctl restart named.service
yum install bind
vim /etc/named.conf
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
root:/var/named # vi /etc/named.rfc1912.zones
zone "beijing.qh.com" IN {
type master;
file "beijing.qh.com.zone";
};
root:/var/named # cp -p named.empty beijing.qh.com.zone
root:/var/named # chmod g+w beijing.qh.com.zone
root:~ $ vim /var/named/beijing.qh.com.zone
$TTL 1D
@ IN SOA master beijing.qh.com. (
2019042214 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
master A 192.168.64.153
websrv A 3.3.3.3
www CNAME websrv #此处可使用别名
root:~ $ systemctl start named.service
root:~ # vim /etc/named.conf #三个不同地区网段
acl beijingnet{
192.168.64.0/24;
};
acl shanghainet{
192.168.65.0/24;
};
acl othernet{
any;
};
view beijingview{
match-clients {beijingnet;};
include "/etc/named/named.rfc1912.zones.bj";
};
view shanghaiview{
match-clients {shanghainet;};
include "/etc/named/named.rfc1912.zones.sh";
};
view otherview{
match-clients {othernet;};
include "/etc/named.rfc1912.zones";
};
############################## zone开头的记录要放到includ包含的/etc/named.rfc1912.zones文件里
root:/var/named # cp -p qh.com.zone qh.com.bj ##创建北京与上海数据库
root:/var/named # cp -p qh.com.zone qh.com.sh
root:/var/named # cat qh.com.bj
$TTL 1D
@ IN SOA master qh.com ( 1 1D 1H 1W 3H )
NS master
master A 192.168.64.151
www A 6.6.6.6
root:/var/named # vi qh.com.sh
$TTL 1D
@ IN SOA master qh.com ( 1 1D 1H 1W 3H )
NS master
master A 192.168.64.151
www A 7.7.7.7
root:/var/named # cp qh.com.sh qh.com.zone #其他地区数据库
cp: overwrite ‘qh.com.zone’? y
root:/var/named # vi qh.com.zone
$TTL 1D
@ IN SOA master qh.com ( 1 1D 1H 1W 3H )
NS master
master A 192.168.64.151
www A 8.8.8.8
root:~ $ cp -p /etc/named.rfc1912.zones /etc/named/named.rfc1912.zones.bj
root:~ $ cp -p /etc/named.rfc1912.zones /etc/named/named.rfc1912.zones.sh
root:/etc/named # vi named.rfc1912.zones.bj
root:/etc/named # vi named.rfc1912.zones.sh
原有named.rfc1912.zones配置不变
#报错
root:/var/named # rndc reload
rndc: connect failed: 127.0.0.1#953: connection refused
# 尝试先重启服务在加载
以64网段
临时加一个网段
服务器:ip a a 192.168.63.1/24 dev ens33
客户端:ip a a 192.168.63.2/24 dev ens33
root:~ # yum install httpd
root:~ # cd /var/www/html/
root:/var/www/html # echo 192.168.64.57,hello >index.html
root:/var/www/html # chmod a+r index.html
root:/var/www/html # service httpd restart
3客户端测试
root:~ # yum install bind
root:~ # vi /etc/named.conf
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
allow-transfer {192.168.64.47;};
root:~ # vi /etc/named.rfc1912.zones
zone "qh.com" IN {
type master;
file "qh.com.zone";
};
root:~ # cd /var/named/
root:/var/named # vi qh.com.zone
$TTL 1D
@ IN SOA ns1 qh.mail.com. ( 1 1H 10M 1D 3H )
NS ns1
NS ns2
ns1 A 192.168.64.37
ns2 A 192.168.64.47
www A 192.168.64.57
root:/var/named # chgrp named qh.com.zone
root:/var/named # chmod 640 qh.com.zone
#### 语法检查
root:/var/named # named-checkconf
#### 启动服务
root:/var/named # systemctl start named.service
root:~ # yum install bind
root:~ # vi /etc/named.conf
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
allow-transfer {none;};
root:~ # vi /etc/named.rfc1912.zones
zone "qh.com" {
type slave;
masters {192.168.64.37;};
file "slaves/qh.com.slave";
};
root:/var/named/slaves # systemctl start named.service
root:/var/named/slaves # rndc reload
root:/var/named/slaves # ll
total #已同步
-rw-r--r-- 1 named named 269 Apr 23 16:34 qh.com.slave
root:~ # yum install bind
root:~ # vi /etc/named.conf
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
allow-transfer {none;};
------------------------------------------------
root:~ # vi /etc/named.rfc1912.zones
zone "com" IN {
type master;
file "com.zone";
};
---------------------------------------------------------
root:~ # cd /var/named/
root:/var/named # vim com.zone
$TTL 1D
@ IN SOA NS1 qh.mail.com. (1 1D 1H 1W 3D )
NS ns1
qh NS qhns1
qh NS qhns2
ns1 A 192.168.64.27
qhns1 A 192.168.64.37 #主服务器
qhns2 A 192.168.64.47 #从服务器
root:/var/named # chgrp named com.zone
root:/var/named # chmod g+w com.zone
root:/var/named # systemctl start named.service
root:/var/named # rndc reload
server reload successful
root:~ # yum install bind
root:~ # vi /etc/named.conf
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
zone "." IN {
type master; #改为master自己做根
file "root.zone";
};
root:~ # cd /var/named/
root:/var/named # vim root.zone
$TTL 1D
@ IN SOA ns1 qh.mail.com. (1 1D 1H 1W 3D )
NS ns1
com NS comns1
ns1 A 192.168.64.17
comns1 A 192.168.64.27
root:/var/named # chgrp named com.zone
root:/var/named # chmod g+w com.zone
root:/var/named # systemctl start named.service
root:~ # yum install bind
root:~ # vi /etc/named.conf
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
root:/etc/sysconfig/network-scripts # vi /var/named/named.ca #改为下面配置
. 518400 IN NS a.root-servers.net.
a.root-servers.net. 3600000 IN A 192.168.64.17
root:/var/named # rndc flush #清理所有dns缓存
root:~ # vi /etc/named.conf
dnssec-enable no;
dnssec-validation no;
root:/var/named # systemctl start named.service
Job for named.service failed because the control process exited with error code. See "systemctl status named.service" and "journalctl -xe" for details.
一般可以通过systemctl status named.service -l 命令可以查看当前错误类型
#dig A example.com ; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> A example.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30523 ... SERVFAIL:The nameserver encountered a problem while processing the query. ? 可使用dig +trace排错,可能是网络和防火墙导致 NXDOMAIN:The queried name does not exist in the zone. ? 可能是CNAME对应的A记录不存在导致 REFUSED:The nameserver refused the client‘s DNS request due to policy restrictions. ? 可能是DNS策略导致 ? NOERROR不代表没有问题,也可以是过时的记录 ?查看是否为权威记录,flags:aa标记判断 ?被删除的记录仍能返回结果,可能是因为*记录存在 ?如:*.example.com. IN A 172.25.254.254 ?注意“.”的使用 ?避免CNAME指向CNAME记录,可能产生回环 ?est.example.com. IN CNAME lab.example.com. ?lab.example.com. IN CNAME test.example.com. ?正确配置PTR记录,许多服务依赖PTR,如sshd,MTA ?正确配置轮询round-robin记录
搭建DNS主从服务器实现反向解析,子域,转发,智能DNS及排错和互联网DNS架构实验
标签:系统 库文件 image 失败 roo blog RoCE ade signed
原文地址:https://blog.51cto.com/9019400/2383531