Domain Name Service( 三 )


After the 12 byte header the DNS query message consists of a block of questions which in turn consist of query name, query type and query class. Typically the query name is the name of site, each component of the name is sent a sequence of characters preceded by a byte holding the binary count of the number of characters in the component. The name is terminated by a zero byte. The query type indicates the type of information required encoded in a 16 bit field. Common values are Name Value Description A 1 IPv4 Address (32 bits) NS 2 Name Server CNAME 5 Canonical Name PTR 12 Pointer Record HINFO 13 Host Information MX 15 Mail Exchange Record TXT 16 Text String AAAA 28 IPv6 Address (128 bits) AXFR 252 Request for Zone Transfer ANY 255 Request for All Records Query class is usually 1 meaning an Internet domain query, other values could be used for different addressing domains. Response Records known as RRs form the body of the reply to a DNS query. They are used for the answers, authority and additional information fields. The form is Bits 0-15 Bits 16-31 Domain Name type class Time to live Resource Data length Resource Data Resource data (continued) The domain name is the query name from the query. The type is the query type. The class is 1 for the Internet domain. The time to live is the time for which the information can be cached by the client, typically two days, eXPressed in seconds. The resource data length specifies the number of bytes of resource data. It is important to note that queries can be made for information relating to both individual hosts and for zones/domains. Most of the query types are fairly obvious. The MX query is used specifically for mail handling and can return information about hosts not directly or regularly connected to the Internet. The result of an MX query for such a host is the address of an Internet host that will receive mail for such a host and make its own arrangements for forwarding the mail via non-Internet means or when the host does connect. An MX query response for a domain provides the address of the host that will handle mail for that domain allowing email addresses of the form User@domain_name. The NS query can be used to identify the name servers for a particular domain.
User InterfacesOn Unix systems the normal user interface is the program /usr/sbin/nslookup. [The actual path may be different on some hosts]. This can be used to perform almost any DNS function and display the results to the user. Here is an example of its use on scitsc.wlv.ac.uk. Note. This example was prepared before the scit.wlv.ac.uk zone was delegated, scitsc is now known as sunc although the old name still works.
bash$ /usr/etc/nslookupDefault Server:scitsc.wlv.ac.ukAddress:134.220.4.1> set q=A> ccub.wlv.ac.uk.Server:scitsc.wlv.ac.ukAddress:134.220.4.1Name:ccub.wlv.ac.ukAddress:134.220.1.20> set q=CNAME> www.wlv.ac.uk.Server:scitsc.wlv.ac.ukAddress:134.220.4.1www.wlv.ac.uk canonical name = ccuf.wlv.ac.uk> set q=MX> wlv.ac.uk.Server:scitsc.wlv.ac.ukAddress:134.220.4.1wlv.ac.uk preference = 1, mail exchanger = wlv.ac.ukwlv.ac.uk inet address = 134.220.1.12> set q=HINFO> ccub.wlv.ac.uk.Server:scitsc.wlv.ac.ukAddress:134.220.4.1ccub.wlv.ac.uk CPU=SUN 690MP OS=Solaris 2.4> set q=PTR> 12.1.220.134.in-addr.arpaServer:scitsc.wlv.ac.ukAddress:134.220.4.112.1.220.134.in-addr.arpa host name = ccug.wlv.ac.ukHere it shows that sunc was providing DNS service. A number of queries were made. The query type was specified using nslookup s set q= command. Type A A simple query for the IP address corresponding to ccub.wlv.ac.uk.
Type CNAME A given host can have several DNS names. One of these is the canonical or reference name. This query reveals that www.wlv.ac.uk is really ccuf.wlv.ac.uk.
Type MX A mail exchanger query, this time for the domain wlv.ac.uk which reveals that mail sent to user@wlv.ac.uk is actually sent to 134.220.1.12 which is really ccug.wlv.ac.uk. (see below).
Type HINFO An HINFO query. This is only useful if the DNS domain administrator has bothered to create the relevant records and keep them up to date.

推荐阅读