A Brief Introduction to the concept of DNS server, and the establishment of a simple DNS name cache server to achieve domain name resolution (1)

Source: Internet
Author: User
Tags domain name server

DNS and Band
DNS: Domain Name System
Working at the application layer, it is a protocol that listens to UDP and TCP ports 53 at the same time.
UDP response query request
TCP response
 
/Etc/Host
At the beginning, there was a relationship between the name you wanted to access and the corresponding name.
However, as the network grows, the management and maintenance of host files becomes very troublesome.
At this time,
The international IP address assignment agency has come up with a method.
They are used for Address Allocation. They regularly spread all the websites by updating the host files on the FTP server.
However, with the explosive growth of the Internet.
Gave birth to the DNS protocol.
The DNS protocol is an extension of the host file, which only fragment the host file.
All users create a database on their own servers and name resolution database.
If someone wants to access a domain name, the database will first go to the DNS to find the corresponding IP address of the domain name.
 
However, this still does not work, and the Internet explosion speed is too fast.
As a result, DNS has enabled its own hierarchical management system.
Like the file system structure, the top-down tree hierarchy
The top is the root node domain name resolution server.
.

. Com. net. org. cn. TW
Top-level domain name country domain name

IBM. | hp. <-------- second-level domain


Tech
Bytes
WWW

 
For example, if IBM has a host named WWW, its name will go from low to high.
Www. IB,. com.
Www.tech.ibm.com.
 
Generally, it can be divided into 63 domain names, and each segment can contain up to 127 domain names.
Generally, we register a second-level domain.
 
How is query implemented?
There are two types of DNS queries:
Recursive query
Recursive
When querying a, you must know the answer once.
A asks B, B doesn't know, but B knows C knows, so B gets the answer from C and tells
Iterative Query
When a queries the answer, the method that is finally queried many times
A asks B, B does not know, but B tells a, c knows, so a asks C again, C tells

On the Internet, users generally query data on the server recursively.
As a server, queries on the Internet are always iterative. It will check all
 
Therefore, applications on the Internet are generally two-step.
Recursion of the first half and iteration of the second half.
 
The Recursion Method consumes a lot of resources. Generally, it only recursion the local client.

Resolution Method
Forward resolution: Name → IP
Reverse resolution: IP → FQDN
 
How is the parsing process implemented?
In the tree structure just now, the upper level will always know the lower level, and the lower level will never know where the upper level is.
Just like IBM never knows where. com is.
 
Therefore, as long as it is a DNS server, it will always know where the root is. This is required.
 
So when www.ibm.com went to www.hp.com
DNS will find the root directly, and the root will tell the DNS not to know, but the com knows, so the DNS will go to com, and then com will tell it that HP may know, so the DNS will go to HP. Finally, the WWW
 
There are 13 root nodes in the world, one in Japan, one in Europe, and the other in the United States.
It is too slow for us to bypass every query, so we have images in China. Our queries are generally queried through the local cache.
 
Sohu.com is generally called a domain name.
While
Www.sohu.com is generally called the Host Name
 
The authorization process is actually called 3A 3A. There is an individual in it responsible for managing all the parsing.
 
A host has a "record type" to indicate its own functions.
So what is a record?
DNS is actually a database, which contains various mappings.
Although they all correspond to each other, the records are different.
Common record types:
1. FQDN --> IP: a record (address)
2. IP --> FQDN: pointer record (PTR)
3. Domain --> server: NS (Name Server)
4. Domain --> MTA: MX (Mail exchanger) is used to identify the mail domain name of a domain
5. Da Ma Zi --> JERRY: cname record type (formal name record type)
6. SOA (start of authority) is used to indicate the start authorization domain type of the current domain.
Generally, it indicates who the Primary Domain Name Server belongs.

DNS server type:
Master name server and slave name server
In order to ensure service availability, we usually configure a person in the same domain to be responsible for government affairs and assist others in government affairs.
This means that we have three servers, each of which knows all the hostnames in the domain clearly. However, if a new host obtains a domain name, it will be created/deleted on the master server. To ensure that the information of other government-assisted servers is consistent with that of the Government-responsible server, the server copies the information on the government-responsible server every time. This method to ensure synchronization is called
Region transfer:
 
Axfr full zone transfer transfers all information
Ixfr incremental region transfer only transfers the new information

Generally, the master server will notify the slave server to synchronize data. Whenever new things enter, they are automatically notified. Synchronize immediately from the server, instead of based on the set synchronization time.
In this way, the master server is directly avoided and the slave server is not updated.

Cache Server
Accelerate access and save bandwidth
After the first person accesses the domain name, if the second person accesses the domain name again, it will directly read it from the cache. There is no real de-connection at all
 
Forwarder:
Implement interaction between two DNS servers isolated from internal and external firewalls
 

Domain
For name resolution:
Forward and reverse will never survive under the same roof
Forward: a separate database file is required.
Reverse: a separate database file is also required.

We have a domain. There are two files in this domain. The two files define all forward and reverse name resolution.
This file is a region.

Region is a logical concept
Domain: it is a logical concept.
This type of transfer is generally performed on the Master/Slave server.
A domain contains a forward region and a reverse region.
The domain and region do not have a fixed inclusion relationship. A domain can contain many regions,
Considering the complete relationship, each subdomain has two files.

How does one query www.a.org?
1. First find the/etc/host file to see if there is a corresponding parsing record in the host file.
2. Find the local DNS cache on the current host
3. Use a client tool to find the first DNS server,
4. the DNS server needs to find the server cache again
5. If no cache is available, check whether the domain is resolved by yourself.
If yes, contact the local domain
Return the result to the Authority for parsing.
---------------------
| Unofficial answer: it is not the domain of the current server, but obtained directly from the cache.
----------------------
6. Find the root ......

This article will introduce how to implement domain name resolution...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.