在一个朋友的blog上看到这篇文章”What is DNS“，描述了DNS的发展历史和基本作用，写的浅显易懂，转帖如下。
The Domain Name System (DNS) is a distributed database that maps domain names to network IP addresses.
That, essentially, is all DNS does. You could navigate around the Internet via IP addresses instead of domain names and just remember that google.com is 188.8.131.52. And in the early days of the Internet in the late 1960’s this is exactly what folks did.
By 1971 the nascent Internet had grown enough that remembering network addresses was a burdensome way to navigate. The solution was a database in a simple text file called hosts.txt that was installed on each machine on the Internet and provided a simple way to map a network address to an easy-to-remember name.
This system worked well but wasn’t very scalable — every time a host was added to the Internet or an network address changed every connected machine had to get an updated hosts.txt file.
A solution called DNS was conceived in 1981 and starting in 1985 the first domain names were registered. Some of the behind the scenes technical details have changed (and continue to evolve), but DNS essentially works today the same as it did in 1985.
We need to define a few terms used in DNS so we have a common vocabulary.
First up is domain name (sometimes just called a domain). You know this one already — g5platform.com, amazon.com, and google.com are all domains.
The information that defines a domain is called a zone.
The actual meat of DNS is contained inside the zone in resource records. These are things with names like “A”, “CNAME” and “MX”. The information in these resource records (or just records) is where the magic of DNS happens.
The “A” record is the most important. This is the address record and maps an IP address to a name.
More history: DNS was designed way before Tim Berners-Lee invented the World Wide Web (WWW or just “web”). Back then you usually didn’t need to access something like mit.edu; this is just the start (a.k.a. origin) of the domain name and before the web more just the origin wouldn’t give you anything. DNS was designed to connect machines, so back then you’d probably want to access another machine with something like swissnet.ai.mit.edu (which would connect you to a machine called swissnet inside the ai sub-zone of the mit.edu zone).
In the early days of the web a host running a domains website was given the name www, stuck in a corner somewhere and put in DNS as www.mit.edu. Eventually new web-only startups arrived who purpose online was the website. For these guys getting the website with just the origin of a domain was a handy way to work. Thus we needed a way to route the origin of a domain name somewhere so amazon.com would work just the same as www.amazon.com.
Luckily the folks that designed DNS were pretty smart and this capability was already implemented. It’s called the origin and you see it in most registrar control panels as the “@” sign. So, when you see an “A” record with an “@” as the host, that’s the origin and all it means is that the start of the domain name will go to the IP address assigned. Simple, huh?
Our next resource record to talk about is related to the above in a way. The “CNAME” record is short for “canonical name”, but is usually just called an alias. It differs from the “A” record in that it doesn’t map to an IP address — it maps to another domain name. It can be a full domain name (like www.amazon.com) or just a host (like www).
A CNAME is the most common way to specify the www record and you just point it to the origin (“@”).
Now, you could do the www as an A record, but if you ever needed to change the IP address your domain points to you’d now have two A records to change. With the www as a CNAME pointing to @ you have only one record to change if your IP address changes. Neat, huh?
Next is the MX records. This is the mail exchanger records and it tells email servers where to send email for your domain. Like the CNAME, it maps to a host or domain name, not an IP address.
There’s other resource records like TXT, SRV and AAAA, but they support more advanced DNS features and you don’t often need to change them.
In summary, DNS appears complicated but in reality it’s just a simple service that maps a name to an address.