DNS and Bind详解

DNS 域名系统(英文:Domain Name System,缩写:DNS)是因特网的一项服务。它作为将域名和IP地址相互映射的一个分布式数据库,能够使人更方便地访问互联网。DNS使用TCP和UDP端口53。

是一个域名服务,应用层协议。


原理篇


DNS组成

    根域(.)

        顶级域(.com, .net, .org, .gov, .edu, .mil,.ac)

            二级域(baidu.com,google.com ... ...)



dns查询

    迭代查询

    递归查询

如下图,从客户端到本地DNS服务器是属于递归查询,而DNS服务器之间的交互查询就是迭代查询。

    wKioL1cJ1tDQCWVNAAFHtqj57Go601.jpg



总结:

1.递归查询:
一般客户机和服务器之间属递归查询,即当客户机向DNS服务器发出请求后,若DNS服务器本身不能解析,则会向另外的DNS服务器发出查询请求,得到结果后转交给客户机;
2.迭代查询(反复查询):
一般DNS服务器之间属迭代查询,如:若DNS2不能响应DNS1的请求,则它会将DNS3的IP给DNS2,以便其再向DNS3发出请求;


所谓递归查询就是:如果主机所询问的本地域名服务器不知道被查询的域名的IP地址,那么本地域名服务器就以DNS客户的身份,向其它根域名服务器继续发出查询请求报文(即替主机继续查询)”
也就是递归就是交给下一个服务器解决(下一个就相当于客户了,所以他也可以选择去递归,或者迭代)(迭代就是返回给当前的,当前自己再去处理)
  递归即递给服务器,所有操作都有服务器来完成。


举例:比如学生问老师一个问题,王老师告诉他答案这之间的叫递归查询。这期间也许王老师也不会,这时王老师问张老师,这之间的查询叫迭代查询!


DNS解析

正向解析区域和反向解析区域

    正向解析是将域名映射为IP地址

        www.baidu.com  --> 202.108.22.5

    反向解析是将IP地址映射为域名

        202.108.22.5  --> www.baidu.com

注意:二者的名称空间,非为同一个空间,即非为同一棵树;因此,也不是同一个解析库;

    

       

主-从DNS服务器

    主DNS服务器:维护所负责解析的域数据库的那台服务器;读写操作均可进行;
     从DNS服务器:从主DNS服务器那里或其它的从DNS服务器那里“复制”一份解析库;但只能进行读操作;

“复制”操作的实施方式:
     序列号:serial, 也即是数据库的版本号;主服务器数据库内容发生变化时,其版本号递增;
     刷新时间间隔:refresh, 从服务器每多久到主服务器检查序列号更新状况;
     重试时间间隔:retry, 从服务器从主服务器请求同步解析库失败时,再次发起尝试请求的时间间隔;
     过期时长:expire,从服务器始终联系不到主服务器时,多久之后放弃从主服务器同步数据;停止提供服务;
     否定答案的缓存时长:
                    
    主服务器”通知“从服务器随时更新数据;
                
区域传送:
     全量传送:axfr, 传送整个数据库;
     增量传送:ixfr, 仅传送变量的数据;
                    <

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Pro DNS and BIND guides you through the challenging array of features surrounding DNS, with a special focus on BIND, the worlds most popular DNS implementation. This book unravels the mysteries of DNS, offering insight into origins, evolution, and key concepts like domain names and zone files. This book focuses on running DNS systems based on BIND 9.3.0the first stable release that includes support for the latest DNSSEC (DNSSEC.bis) standards and a major functional upgrade from previous BIND 9 releases. If you administer a DNS system or are thinking about running one, or if you need to upgrade to support IPv6 DNS, need to secure a DNS for zone transfer, dynamic update, or other reasons, or if you need to implement DNSSEC, or simply want to understand the DNS system, then this book provides you with a single point of reference. Pro DNS and BIND starts with simple concepts, then moves on to full security-aware DNSSEC configurations. Various features, parameters, and resource records are described and, in the majority of cases, illustrated with one or more examples. The book contains a complete reference to zone files, Resource Records, and BINDs configuration file parameters. You can treat the book as as a simple paint-by-numbers guide to everything from a simple caching DNS, to the most complex secure DNS (DNSSEC) implementation. Background information is still included for when you need to know what to do and why you have to do it, and so that you can modify processes to meet your unique needs.
std::bind是C++11引入的函数对象适配器,用于将函数对象(包括普通函数、成员函数、函数指针等)与其参数进行绑定,生成一个新的函数对象。 它的基本语法如下: ```cpp template< class Fn, class... Args > bind( Fn&& fn, Args&&... args ); ``` 其中,Fn表示要绑定的函数对象(可以是普通函数、成员函数、函数指针等),Args表示要绑定的参数。 使用std::bind可以实现参数的绑定、参数重排、占位符等功能。下面是一些示例: 1. 绑定普通函数: ```cpp #include <iostream> #include <functional> void foo(int a, int b) { std::cout << "a + b = " << a + b << std::endl; } int main() { auto func = std::bind(foo, 1, 2); func(); // 输出:a + b = 3 return 0; } ``` 2. 绑定成员函数: ```cpp #include <iostream> #include <functional> class Foo { public: void bar(int a, int b) { std::cout << "a + b = " << a + b << std::endl; } }; int main() { Foo obj; auto func = std::bind(&Foo::bar, &obj, 1, 2); func(); // 输出:a + b = 3 return 0; } ``` 3. 参数重排: ```cpp #include <iostream> #include <functional> void foo(int a, int b) { std::cout << "a + b = " << a + b << std::endl; } int main() { auto func = std::bind(foo, std::placeholders::_2, std::placeholders::_1); func(2, 1); // 输出:a + b = 3 return 0; } ``` 在这个示例中,使用std::placeholders::_1和std::placeholders::_2来表示占位符,表示在调用func时,第一个参数将会被传递给foo的第二个参数,第二个参数将会被传递给foo的第一个参数。 这些仅是std::bind的一些基本用法,它还提供了更多的功能和特性,可以根据具体需求进行学习和使用。希望能对你有所帮助!

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值