计算机网络 --- DNS协议
什么是DNS
- 一个将域名转换为IP地址的directory service
- A distributed and hierarchical database implemented in a hierarchy of DNS servers
- An application-layer protocol that allows hosts to query the distributed database
- DNS protocol runs over UDP and uses port 53
DNS工作原理
Overview
Step 1: the application, such as browser, will invoke the client side of DNS, specifying the hostname that needs to be translated (use gethostbyname())
Step 2: DNS in the user’s host then takes over, sending a query message into the network. (using UDP and port 53)
Step 3: After a delay, DNS in the user’s host receives a DNS reply message that provides the desired mapping and passed to the invoking application.
Three Classes of DNS servers
1: Root servers
- 13 root servers managed by 13 different organizations
- provide the IP addresses of the TLD servers
2: top-level domain DNS servers
- For each of the top-level domains (com, .org, .uk, .fr, .cn) has a TLD server
- provide IP addresses for authoritative DNS server.
3: authoritative DNS servers
- Every organization with publicly accessible hosts on the internet has an authoritative DNS server.
- The organization can build its own DNS server or pay to use third-party DNS server.
Local DNS server (ISP server)
- Each ISP—such as a residential ISP or an institutional ISP—has a local DNS server (also called a default name server).
- When a host makes a DNS query, the query is sent to the local DNS server, which acts a proxy, forwarding the query into the DNS server hierarchy
Two Types of Query
Iterative query
Recursive query (usually used)
DNS Caching
Each time the local DNS server dns.nyu.edu receives a reply from some DNS server, it can cache any of the information contained in the reply. If a hostname/IP address pair is cached in a DNS server and another query arrives to the DNS server for the same hostname, the DNS server can provide the desired IP address.