当前位置: 首页 > article >正文

DNS(Bind9) Anycast 数据中心部署 最终版

DNS(Bind9) Anycast 数据中心部署 最终版

问题点:

现网使用的是windows ad域控加windows dns的结构,支撑全网设备的加域和域名解析功能,但由于部分终端机不能动态更换dns服务器ip,会出现某台dns服务器宕机,业务中断的情况。现使用dns的虚拟化技术来提高dns的可用性。

技术要点:

dns anycast:将多个dns的ip虚拟成一个独立的ip对外提供服务,全机房均可以访问这个ip,当某一个dns服务器宕机,请求会被发送到剩余存活服务器中最近的一台。
anycast:Anycast实质上是一种网络技术,它借助于网络中动态路由协议实现服务的负载均衡和冗余。
动态路由:动态路由是指路由器能够自动地建立自己的路由表,并且能够根据实际情况的变化适时地进行调整。

单播,多播,广播,任意播:

Unicast IP 单播

IP地址和主机是一一对应关系。

Multicast IP组播IP:

组播IP拥有特定的IP地址段,当数据包发送给此组播IP地址后,组内成员都能收到此数据包。

Broadcast IP广播IP:

广播的ip是单播网段中最后一个IP地址。数据包发送给此地址会扩散给全广播域的成员。

Anycast IP任意播

从宏观上来说,Anycast类似于Multicast,同一种类型的数据流同时存在多个接收者。而从微观上来说,Anycast又有着Unicast的唯一性。每一个单独的IP会话都能够找到唯一的源主机和目标主机。

Anycast技术具有以下优势:

一、不同客户端将访问不同目的主机,此过程对客户端透明,从而实现了目的主机的负载均衡;

二、当任意目的主机接入的网络出现故障,导致该目的主机不可达时,客户端请求可以在无人为干预的情况下自动被路由到目前可达的最近目的主机,在一定程度上为目标主机提供了冗余性;

三、当目的主机受到DoS攻击而无法到达时,由于网络不可到达,客户端请求也将路由到其他目的主机上,而在DDoS攻击时,由于Anycast的负载均衡效应,避免了单台目的主机承受所有攻击流量,因此在一定程度上为目的主机提高了安全性;

四、因为Anycast利用路由度量到“最近”的目的主机,提高了客户端响应速度。

使用到的软件:

bind9
quagga

架构图:

拓扑图:

安装

yum -y install bind
查看版本

[root@ADClient03 etc]# named -v
BIND 9.9.4-RedHat-9.9.4-61.el7_5.1 (Extended Support Version)

关闭selinux

[root@ADClient03  ~]# cat /etc/selinux/config   
# This file controls the state of SELinux on the system.  
# SELINUX= can take one of these three values:  
#     enforcing - SELinux security policy is enforced.  
#     permissive - SELinux prints warnings instead of enforcing.  
#     disabled - No SELinux policy is loaded.  
#SELINUX=enforcing  
SELINUX=disabled  
# SELINUXTYPE= can take one of three two values:  
#     targeted - Targeted processes are protected,  
#     minimum - Modification of targeted policy. Only selected processes are protected.   
#     mls - Multi Level Security protection.  
SELINUXTYPE=targeted   

配置文件

位置:/etc/named.conf

options {listen-on port 53 { any; };directory   "/var/named";recursion yes;allow-query     { any; };forwarders {10.205.40.137;10.206.40.137;};forward only;dnssec-enable yes;dnssec-validation yes;auth-nxdomain no;    # conform to RFC1035listen-on-v6 { any; };
};
logging {channel query_log {file "query.log"  versions 3 size 200m; severity dynamic;   #记录信息级别print-time yes; #记录时间print-category  yes;    #记录类型};category queries {query_log;};  #请求记录category unmatched{query_log;}; #未匹配的查询category xfer-in {query_log;};  #接收区域传输category xfer-out {query_log;}; #发送区域传输category notify {query_log;};   #NOTIFY协议category update {query_log;};   #动态更新category resolver {query_log;};category unmatched {query_log;};
};zone "_msdcs.te.com" IN {type slave;     #类型file "slaves/msdcs.te.com.zone";masters { 10.202.10.6;10.202.10.7; };masterfile-format text;allow-transfer{ none; };    check-names ignore;
};zone "te.com" IN{type slave; #类型file "slaves/te.com.zone";  #数据存储位置,请放在slave文件夹下,自动生成masters { 10.202.10.6;10.202.10.7; };   #master dns的ip地址masterfile-format text;     #将从windows dns 同步过来的数据修改改成text格式allow-update-forwarding { any; };   #允许动态更新的ip地址集allow-transfer{ none; };    #允许同步的ip地址集#request-ixfr yes;  #slave 使用ixfr更新,默认开启
};zone "GD.com" IN {type forward ;forwarders{10.205.40.155;
};
};zone "10.202.10.in-addr.arpa" IN{type slave;file "slaves/10.202.10.db";masters { 10.202.10.6;10.202.10.7; };   masterfile-format text; allow-transfer{ none; };    
};zone "10.10.10.in-addr.arpa" IN{type slave;file "slaves/10.10.10.db";masters { 10.202.10.6;10.202.10.7; };   masterfile-format text; allow-transfer{ none; };    
};

同步方式:AXFR/IXFR

AXFR:完全区域传输(Full Zone Transfer,AXFR)
IXFR:增量区域传输(Incremental Zone Transfer)
IXFR的局限性:BIND9之后才支持

IXFR是否开启:默认开启

provide-ixfr
provide-ixfr yes|no ;
The provide-ixfr option defines whether a master will respond to an incremental zone transfer request(IXFR) (option = yes) or will respond with a full zone transfer (AXFR) (option = no). The default is yes. This statement may be specified in normal server or view clauses or in a global options clause.

request-ixfr
request-ixfr yes|no ;
Applies to slave zones only. The request-ixfr option defines whether a server will request an incremental zone transfer (IXFR) (option = yes) or will request a full zone transfer (AXFR) (option = no). The default is yes. This statement may be specified in normal server or view clauses or in a global options clause.

资料:
DNS BIND Zone Transfers and Updates
http://www.zytrax.com/books/dns/ch7/xfer.html

日志验证:
08-Nov-2018 18:16:06.157 xfer-in: transfer of 'te.com/IN' from 10.136.4.144#53: connected using 10.136.4.99#42010
08-Nov-2018 18:16:06.227 xfer-in: transfer of 'te.com/IN' from 10.136.4.144#53: Transfer completed: 13 messages, 8167 records, 203502 bytes, 0.069 secs (2949304 bytes/sec)
08-Nov-2018 18:20:48.230 xfer-in: transfer of 'te.com/IN' from 10.136.4.144#53: connected using 10.136.4.99#55718
08-Nov-2018 18:20:48.298 xfer-in: transfer of 'te.com/IN' from 10.136.4.144#53: Transfer completed: 2 messages, 796 records, 20049 bytes, 0.068 secs (294838 bytes/sec)
09-Nov-2018 09:56:09.662 xfer-in: transfer of 'te.com/IN' from 10.136.4.144#53: connected using 10.136.4.99#46531
09-Nov-2018 09:56:09.713 xfer-in: transfer of 'te.com/IN' from 10.136.4.144#53: Transfer completed: 1 messages, 5 records, 215 bytes, 0.051 secs (4215 bytes/sec)
09-Nov-2018 10:00:40.715 xfer-in: transfer of 'te.com/IN' from 10.136.4.144#53: connected using 10.136.4.99#48270
09-Nov-2018 10:00:40.775 xfer-in: transfer of 'te.com/IN' from 10.136.4.144#53: Transfer completed: 1 messages, 5 records, 215 bytes, 0.059 secs (3644 bytes/sec)

目前god中已有8000多条信息,经测试,从windows同步到bind中,AXFR单次同步203502 bytes大小的文件,耗时0.069 secs

动态更新

服务器主动将自己的hostname和ip注册到dns中。
通过配置bind中的allow-update-forwarding,可以将注册数据包转发到master上,待master中写入完成过后,通过同步功能同步到slave中。

递归查询

允许递归查询,主动向8.8.8.8进行查询。

日志配置

请参考
参数:
http://www.zytrax.com/books/dns/ch7/logging.html
log配置例子:
https://blog.csdn.net/zhu_tianwei/article/details/45103455

windows dns 添加区域传送区域更新通知两个权限

动态路由

使用ospf技术,利用quagga软件模拟交换机发送ospf报文,和交换机建邻居并宣告虚拟ip对应的路由条目。

yum -y install bind
service named start
chkconfig named on 
named -v
cat /etc/selinux/config ##disable  
yum -y install quagga
service zebra start
chkconfig zebra on 
cp /usr/share/doc/quagga-0.99.22.4/ospfd.conf.sample /etc/quagga/ospfd.conf
chown quagga:quagga /etc/quagga/ospfd.conf
service ospfd start
chkconfig ospfd on

使用vtysh进入quagga

vtysh
conf t
interface eth0ip address 10.10.10.10/32ip address 10.202.10.10/24
router ospfospf router-id 10.202.10.10log-adjacency-changes detailnetwork 10.10.10.10/32 area 0.0.0.1network 10.202.10.10/24 area 0.0.0.1
!
end
wr
quit

windows 批量添加DNS的A记录和PTR记录

# dnscmd [DNS] /RecordAdd [域] [主机名] A [IP]
dnscmd . /RecordAdd te.com hostA A 172.16.2.1
dnscmd . /RecordAdd te.com hostB A 172.16.2.2
dnscmd . /RecordAdd te.com hostC A 172.16.2.3
dnscmd . /RecordAdd te.com hostD A 172.16.2.4

细节:

  • 10.202.10.6和10.202.10.7是域控,在使用此技术情况下,通过nslookup解析te.com,结果显示10.202.10.6和10.202.10.7,并不会显示10.10.10.10。
  • dns anycast服务器作为辅助域控,虚拟机指向10.10.10.10可以加域和动态更新dns,如果作为转发服务器,只能加域无法动态跟新dns。
  • bind的forwards是顺序询问,直到有一个回复。
  • windows dns 开通通知功能,同步时间更短。
  • windows AD和windows DNS不能分离,因为msdcs中有部分域信息使用hash码,手工不容易配置。
  • 在不修改ospf的hello和dead时间的情况下,dns anycast服务器宕机,受影响主机40s后才能正常访问。

资料

ixfr资料:基本理念可以,但是比较老。
https://yq.aliyun.com/articles/102290
BIND9.11 官方文档资料:
https://www.isc.org/bind-9-11-arm/
DNS BIND Zone Transfers and Updates
http://www.zytrax.com/books/dns/ch7/xfer.html
参数:
http://www.zytrax.com/books/dns/ch7/logging.html
log配置例子:
https://blog.csdn.net/zhu_tianwei/article/details/45103455
anycast:
https://ddiguru.com/blog/118-introduction-to-anycast-dns

http://www.lryc.cn/news/2417180.html

相关文章:

  • Linux淘金记(一):module_init——初始化就该这么写
  • IOS-Moya简单使用-Swift
  • Myo肌电臂环中文入门指南及基于matlab获取Myo臂环信号
  • C++11重写muduo网络库——预备知识
  • 行业分析
  • 为什么有时候启动Activity需要加FLAG_ACTIVITY_NEW_TASK
  • 制作一个简单HTML中华传统文化网页设计源码(HTML+CSS)
  • GRUB4DOS使用大全
  • 《Head first Java》练习
  • asdasdasdasdasdas
  • 位图(bmp)文件格式分析
  • CPU架构名词解释
  • 计算机网络之网络基础网络通信原理(非常重要的网络基础知识,内含思维导图和详细图解)
  • 药娘化女仆公读《乡村振兴战略下传统村落文化旅游设计》晏嘤茹苦辉少许
  • 大家厚爱
  • maven冲突解决-enforcer插件介绍
  • 数学规划模型之线性规划
  • 操作系统实验二·生产者消费者问题
  • CodeProject SenseAI服务器:AI最简单的方法
  • 点对点 端到端的区别
  • 【论文阅读】HGT:Heterogeneous Graph Transformer
  • 网络分析——路径分析
  • [计算机效率] 磁盘优化及清理
  • 【已解决】ping: www.baidu.com: 未知的名称或服务
  • linux系统安装步骤
  • _Deallocate 造成 Exception:(_Ptr_user(_BIG_ALLOCATION_ALIGNMENT-1))==0
  • 《新人皮灯笼》里白扇子谋权篡位的暗线
  • 十进制二进制转换简单说明
  • 桌面精灵制作记录
  • linux 搭建webserver-Goahead