rfc2168.txt
来自「RFC 的详细文档!」· 文本 代码 · 共 1,124 行 · 第 1/4 页
TXT
1,124 行
Daniel & Mealling Experimental [Page 5]
RFC 2168 Resolution of URIs Using the DNS June 1997
Note that the client applies all the substitutions and performs all
lookups, they are not performed in the DNS servers. Note also that it
is the belief of the developers of this document that regexps should
rarely be used. The replacement field seems adequate for the vast
majority of situations. Regexps are only necessary when portions of a
namespace are to be delegated to different resolvers. Finally, note
that the regexp and replacement fields are, at present, mutually
exclusive. However, developers of client software should be aware
that a new flag might be defined which requires values in both
fields.
Example 1
---------
Consider a URN that uses the hypothetical DUNS namespace. DUNS
numbers are identifiers for approximately 30 million registered
businesses around the world, assigned and maintained by Dunn and
Bradstreet. The URN might look like:
urn:duns:002372413:annual-report-1997
The first step in the resolution process is to find out about the
DUNS namespace. The namespace identifier, "duns", is extracted from
the URN, prepended to urn.net, and the NAPTRs for duns.urn.net looked
up. It might return records of the form:
duns.urn.net
;; order pref flags service regexp replacement
IN NAPTR 100 10 "s" "dunslink+N2L+N2C" "" dunslink.udp.isi.dandb.com
IN NAPTR 100 20 "s" "rcds+N2C" "" rcds.udp.isi.dandb.com
IN NAPTR 100 30 "s" "http+N2L+N2C+N2R" "" http.tcp.isi.dandb.com
The order field contains equal values, indicating that no name
delegation order has to be followed. The preference field indicates
that the provider would like clients to use the special dunslink
protocol, followed by the RCDS protocol, and that HTTP is offered as
a last resort. All the records specify the "s" flag, which will be
explained momentarily. The service fields say that if we speak
dunslink, we will be able to issue either the N2L or N2C requests to
obtain a URL or a URC (description) of the resource. The Resource
Cataloging and Distribution Service (RCDS)[7] could be used to get a
URC for the resource, while HTTP could be used to get a URL, URC, or
the resource itself. All the records supply the next domain name to
query, none of them need to be rewritten with the aid of regular
expressions.
Daniel & Mealling Experimental [Page 6]
RFC 2168 Resolution of URIs Using the DNS June 1997
The general case might require multiple NAPTR rewrites to locate a
resolver, but eventually we will come to the "terminal NAPTR". Once
we have the terminal NAPTR, our next probe into the DNS will be for a
SRV or A record instead of another NAPTR. Rather than probing for a
non-existent NAPTR record to terminate the loop, the flags field is
used to indicate a terminal lookup. If it has a value of "s", the
next lookup should be for SRV RRs, "a" denotes that A records should
sought. A "p" flag is also provided to indicate that the next action
is Protocol-specific, but that looking up another NAPTR will not be
part of it.
Since our example RR specified the "s" flag, it was terminal.
Assuming our client does not know the dunslink protocol, our next
action is to lookup SRV RRs for rcds.udp.isi.dandb.com, which will
tell us hosts that can provide the necessary resolution service. That
lookup might return:
;; Pref Weight Port Target
rcds.udp.isi.dandb.com IN SRV 0 0 1000 defduns.isi.dandb.com
IN SRV 0 0 1000 dbmirror.com.au
IN SRV 0 0 1000 ukmirror.com.uk
telling us three hosts that could actually do the resolution, and
giving us the port we should use to talk to their RCDS server. (The
reader is referred to the SRV proposal [4] for the interpretation of
the fields above).
There is opportunity for significant optimization here. We can return
the SRV records as additional information for terminal NAPTRs (and
the A records as additional information for those SRVs). While this
recursive provision of additional information is not explicitly
blessed in the DNS specifications, it is not forbidden, and BIND does
take advantage of it [8]. This is a significant optimization. In
conjunction with a long TTL for *.urn.net records, the average number
of probes to DNS for resolving DUNS URNs would approach one.
Therefore, DNS server implementors SHOULD provide additional
information with NAPTR responses. The additional information will be
either SRV or A records. If SRV records are available, their A
records should be provided as recursive additional information.
Note that the example NAPTR records above are intended to represent
the reply the client will see. They are not quite identical to what
the domain administrator would put into the zone files. For one
thing, the administrator should supply the trailing '.' character on
any FQDNs.
Daniel & Mealling Experimental [Page 7]
RFC 2168 Resolution of URIs Using the DNS June 1997
Example 2
---------
Consider a URN namespace based on MIME Content-Ids. The URN might
look like this:
urn:cid:199606121851.1@mordred.gatech.edu
(Note that this example is chosen for pedagogical purposes, and does
not conform to the recently-approved CID URL scheme.)
The first step in the resolution process is to find out about the CID
namespace. The namespace identifier, cid, is extracted from the URN,
prepended to urn.net, and the NAPTR for cid.urn.net looked up. It
might return records of the form:
cid.urn.net
;; order pref flags service regexp replacement
IN NAPTR 100 10 "" "" "/urn:cid:.+@([^\.]+\.)(.*)$/\2/i" .
We have only one NAPTR response, so ordering the responses is not a
problem. The replacement field is empty, so we check the regexp
field and use the pattern provided there. We apply that regexp to the
entire URN to see if it matches, which it does. The \2 part of the
substitution expression returns the string "gatech.edu". Since the
flags field does not contain "s" or "a", the lookup is not terminal
and our next probe to DNS is for more NAPTR records:
lookup(query=NAPTR, "gatech.edu").
Note that the rule does not extract the full domain name from the
CID, instead it assumes the CID comes from a host and extracts its
domain. While all hosts, such as mordred, could have their very own
NAPTR, maintaining those records for all the machines at a site as
large as Georgia Tech would be an intolerable burden. Wildcards are
not appropriate here since they only return results when there is no
exactly matching names already in the system.
The record returned from the query on "gatech.edu" might look like:
gatech.edu IN NAPTR
;; order pref flags service regexp replacement
IN NAPTR 100 50 "s" "z3950+N2L+N2C" "" z3950.tcp.gatech.edu
IN NAPTR 100 50 "s" "rcds+N2C" "" rcds.udp.gatech.edu
IN NAPTR 100 50 "s" "http+N2L+N2C+N2R" "" http.tcp.gatech.edu
Daniel & Mealling Experimental [Page 8]
RFC 2168 Resolution of URIs Using the DNS June 1997
Continuing with our example, we note that the values of the order and
preference fields are equal in all records, so the client is free to
pick any record. The flags field tells us that these are the last
NAPTR patterns we should see, and after the rewrite (a simple
replacement in this case) we should look up SRV records to get
information on the hosts that can provide the necessary service.
Assuming we prefer the Z39.50 protocol, our lookup might return:
;; Pref Weight Port Target
z3950.tcp.gatech.edu IN SRV 0 0 1000 z3950.gatech.edu
IN SRV 0 0 1000 z3950.cc.gatech.edu
IN SRV 0 0 1000 z3950.uga.edu
telling us three hosts that could actually do the resolution, and
giving us the port we should use to talk to their Z39.50 server.
Recall that the regular expression used \2 to extract a domain name
from the CID, and \. for matching the literal '.' characters
seperating the domain name components. Since '\' is the escape
character, literal occurances of a backslash must be escaped by
another backslash. For the case of the cid.urn.net record above, the
regular expression entered into the zone file should be
"/urn:cid:.+@([^\\.]+\\.)(.*)$/\\2/i". When the client code actually
receives the record, the pattern will have been converted to
"/urn:cid:.+@([^.]+\.)(.*)$/\2/i".
Example 3
---------
Even if URN systems were in place now, there would still be a
tremendous number of URLs. It should be possible to develop a URN
resolution system that can also provide location independence for
those URLs. This is related to the requirement in [1] to be able to
grandfather in names from other naming systems, such as ISO Formal
Public Identifiers, Library of Congress Call Numbers, ISBNs, ISSNs,
etc.
The NAPTR RR could also be used for URLs that have already been
assigned. Assume we have the URL for a very popular piece of
software that the publisher wishes to mirror at multiple sites around
the world:
http://www.foo.com/software/latest-beta.exe
Daniel & Mealling Experimental [Page 9]
RFC 2168 Resolution of URIs Using the DNS June 1997
We extract the prefix, "http", and lookup NAPTR records for
http.urn.net. This might return a record of the form
http.urn.net IN NAPTR
;; order pref flags service regexp replacement
100 90 "" "" "!http://([^/:]+)!\1!i" .
This expression returns everything after the first double slash and
before the next slash or colon. (We use the '!' character to delimit
the parts of the substitution expression. Otherwise we would have to
use backslashes to escape the forward slashes, and would have a
regexp in the zone file that looked like
"/http:\\/\\/([^\\/:]+)/\\1/i".).
Applying this pattern to the URL extracts "www.foo.com". Looking up
NAPTR records for that might return:
www.foo.com
;; order pref flags service regexp replacement
IN NAPTR 100 100 "s" "http+L2R" "" http.tcp.foo.com
IN NAPTR 100 100 "s" "ftp+L2R" "" ftp.tcp.foo.com
Looking up SRV records for http.tcp.foo.com would return information
on the hosts that foo.com has designated to be its mirror sites. The
client can then pick one for the user.
NAPTR RR Format
===============
The format of the NAPTR RR is given below. The DNS type code for
NAPTR is 35.
Domain TTL Class Order Preference Flags Service Regexp
Replacement
where:
Domain
The domain name this resource record refers to.
TTL
Standard DNS Time To Live field
Class
Standard DNS meaning
Daniel & Mealling Experimental [Page 10]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?