Solaris - dns名称解析过程[中文]

发表于:2007-06-09来源:作者:点击数: 标签:
心情不错,翻译josephxd贴上来的Solaris-dns名称解析过程,请笑纳。 声明:不负责由于错误翻译误导而导致的任何损失。欢迎转载。) Solaris-dns名称解析过程[中文] [译]Samhoo 本文的目的在于阐述DNS名称解析过程。为了给出一个例子,我们假设某个用户试图从

心情不错,翻译josephxd贴上来的Solaris - dns名称解析过程,请笑纳。
声明:不负责由于错误翻译误导而导致的任何损失。欢迎转载。)

Solaris - dns名称解析过程[中文]


[译]Samhoo

本文的目的在于阐述DNS名称解析过程。为了给出一个例子,我们假设某个用户试图从客户机ftp到ftp.internic.net

该客户机将经历如下解析步骤:

1. 客户机根据/etc/nsswitch.conf文件来确定名字解析的顺序。在本例中,假定的顺序是:首先是本地文件,其次

NIS+服务器,最后是DNS。

2. 客户机查找本地/etc/inet/hosts文件,没有发现匹配项。


3. 客户机向NIS+服务器发起关于ftp.internic.net地址的查询,仍然没有找到。


4. 客户机根据/etc/resolv.conf文件确定名称解析搜索列表和本地DNS服务器的地址。


5. 客户机解析例程向本地DNS服务器发起一个递归的DNS查询,以返回ftp.intenic.net的地址。这次,客户机将阻塞直

到本地DNS服务器完成名称解析。


6. 如果该查询最近出现过,本地DNS服务器首先会检查缓冲。如果该查询结果在本地缓冲里,它向客户机返回一个非权

威的查询结果


7. 本地DNS服务器向负责internic.net域查询的DNS服务器(如果没有适当的DNS服务器就向根服务器)发起一个交互查

询。在本例中,我们假设缓冲中没有所需的查询结果,而且根服务器服务于我们的查询。


8. 根服务器返回最接近的信息。这样,你只能从根服务器得到的所有net.服务器的名称和地址。根服务器返回的这些

名称和地址还包含了维持时间(time-to-alive),维持时间用于通知本地域名服务器,这些名称和地址可以缓冲多长

时间。


9. 本地DNS服务器向上一步查询返回的net.服务器的其中之一发起查询,查询的过程与上述向根服务器进行的交互查询

是一样的。


10. net.服务器返回最为接近的信息--internic.net.服务器的地址和名称及其维持时间(time-to-live)。


11. 本地DNS服务器向其中的一个internic.net.服务器发起相同的查询。


12. internic.net.服务器返回ftp.internic.net的地址及其维持时间(time-to-live)。


13. 本地DNS服务器向客户机返回所请求的地址,然后就可以处理ftp命令。


14. 本地DNS服务器将缓冲ftp.internic.net的地址用于以后的查询。


附原文:
The purpose of this infodoc is to explain the DNS Name Resolution Process. To use an example, let's say 

a user is trying to ftp to ftp.internic.net from a client machine. The client machine resolution process 

uses the following steps: 
1. The client system consults the /etc/nsswitch.conf file to determine the name resolution order. In 

this example, the presumed order is local files first, NIS+ server second, and DNS third. 

2. The client system consults the local /etc/inet/hosts file and does not find an entry. 

3. The client system sends a query regarding the address of ftp.internic.net to the NIS+ server and 

finds none. 

4. The client system consults the /etc/resolv.conf file to determine the name resolution search list and 

the address of the local DNS server. 

5. The client system resolver routines send a recursive DNS query regarding the return address of 

ftp.internic.net to the local DNS server. At this point, the client will wait until the local server has 

completed name resolution. 

6. The local DNS server consults the contents of its cached information in case this query has been 

tried recently. If the answer is in local cache, it is returned to the client as a non-authoritative 

answer. 

7. The local DNS server contacts the appropriate DNS server for the internic.net domain (if known) or a 

root server, and sends an iterative query. In this example, the assumption is that the answer is not 

cached and root server must be contacted. 

8. The root server returns the best information it has. In this case, the only information you can be 

guaranteed that the root server will have is the names and addresses of all the net.servers. The root 

server returns these names and addresses along with a time-to-live value specifying how long the local 

name server can cache this information. 

9. The local DNS server contacts one of the net.servers returned from the previous query, and transmits 

the same iterative query sent to the root servers earlier. 

10. The net.server contacted returns the best information it has, which is the names and addresses of 

the internic.net. servers along with a time-to-live value. 

11. The local DNS server contacts one of the internic.net. servers and makes the same query. 

12. The internic.net. servers return the address of the ftp.internic.net along with the time-to-live 

value. 

13. The local DNS server returns the requested address to the client system and the ftp command can 

proceed. 

14. Now this address for ftp.internic.net will be cached in local DNS server for future queries.


 科学球 回复于:2002-10-09 10:41:16
雪中送炭啊。我正看的头大呢。不过照此文章看,我能不能放弃本地的/etc/nsswitch.conf中指定的本地解析,只依赖/etc/resolv.conf中指定的DNS服务器呢?不知道我这样问是不是很傻,呵呵。

如果可以,为什么如果我不在/etc/nsswitch.conf中指定,DNS就不通呢?

 sohu3370 回复于:2002-10-09 10:50:16
[quote][b]下面引用由[u]科学球[/u]在 [i]2002/10/09 10:41am[/i] 发表的内容:[/b]
雪中送炭啊。我正看的头大呢。不过照此文章看,我能不能放弃本地的/etc/nsswitch.conf中指定的本地解析,只依赖/etc/resolv.conf中指定的DNS服务器呢?不知道我这样问是不是很傻,呵呵。
如果可以,为什么如果我 ...
[/quote]

也就是说只在/etc/resolv.conf文件中设置--hosts:dns,而不设--hosts:files dns对吧!

应该没问题!

 科学球 回复于:2002-10-09 10:52:02
这样做之后就不会通过/etc/hosts文件了吗?

 josephxd 回复于:2002-10-09 11:35:02
是这个意思。

 阿骁 回复于:2002-10-09 13:02:24
[这个贴子最后由阿骁在 2002/10/20 04:49pm 编辑]

/etc/nsswitch.conf文件中的hosts:files dns设置是很灵活的,顺序也可以随意调整。达到灵活配置的目的。如果设置成hosts:dns files,那么当dns无法起作用的时候,还能通过使用hosts文件来解析域名。我自己比较喜欢先files然后在dns,这样在解析本地域名的时候会快些。

 163 回复于:2002-10-20 15:00:10
[这个贴子最后由163在 2002/10/20 03:03pm 编辑]

是雪中送炭啊。我正在查阅
/etc/nsswitch.conf //判别域名解析使用的方式顺序。
/etc/resolv.conf //如使用了dns则使用其中的默认域名和服务器进行解析。
/etc/inet/hosts //本机上的主机表方式查询的数据库
等文件的关系呢。

楼上的朋友,我记得在/etc/resolv.conf中只有domain search nameserver的项目吧。至于你说的本机要的解析服务查找方式顺序选择就是/etc/nsswitch.conf中的hosts:字段中的吧

还请指教。



 阿骁 回复于:2002-10-20 16:51:24
不好意思,我写错了,应该是nsswitch.conf文件,我改过来了。

原文转自:http://www.ltesting.net