Build your own CDN with DNSPod and Squid (2)

Source: Internet
Author: User
Tags nslookup nslookup command

Chapter 2 set the DNS of a domain name

Let's warm up first before the beginning.
Intelligent DNS is the foundation of CDN. I believe that there will always be two links on the home page. For telecom users, visit Main Site A and for Netcom users, visit image site B. Then there are two domain names. www.naizhao.com points to A and cnc.naizhao.com points to B. After reading it for a long time, the user felt dizzy and casually clicked it in. He found that the access speed was really good. It is estimated that the entire webpage was opened and China had entered the communist society.
With Intelligent DNS, the above problems can be solved. The user only needs to enter www.naizhao.com, and the system will automatically determine whether the user is accessing the Internet through a telecom line or a Netcom line, and then automatically return the IP address of the server of the Telecom or China Netcom. The whole process is invisible to users. Users only feel that the web page is opened after a click, which is a great experience.
Let's do it!

1. Add a domain name on DNSPod
Open www.dnspod.com, select register from the navigation menu in the upper right corner, and enter the information as prompted to complete registration. After successful registration, return to the home page to log on.
After logging on, you will see a box for adding a new domain name. Enter naizhao (do not enter www. In addition, the example in this article is naizhao.com), select. com on the right, and click Add.

After the domain name is added, the system automatically jumps to the newly added domain name management page. You can see that there is nothing in it. Don't worry. Let's take a look.
You can see several input boxes and drop-down lists at the bottom of the page to add resolution records. Let's try to add a telecom record first. Enter the following format:
Host record: www
Record type:
Line type: China Telecom
Record value: 1.1.1.1
Priority: (left empty)
TTL: 3600 (default)
Click Add.

There are several points to explain:
Host record: that is, the thing before the domain name, such as www. After the record takes effect, it is www.naizhao.com. If you want to implement naizhao.com (without www), leave it blank when adding it. The system will automatically add a @ to it, representing the domain name itself.
Record types: A, CNAME, and MX. The most common one is A, and the record value is an IP address. In addition, MX, that is, mail record, is used in the mail server. We will not discuss it in detail here.
Line type: Important. If China Telecom is selected, this record * can only be resolved to telecom users, but not to Netcom users. If you add only one Telecom record to a domain name, the Netcom user will not be able to access it. In the same way, China Netcom has the same line type. Note: Non-Netcom and non-CERNET users will be resolved to the telecommunications record. That is to say, foreign users, China tietong, China Unicom, and other users will be resolved to the Telecom server.
There is also a general purpose, which means that you can parse this record whether you are a telecom or China Netcom or other users. We do not recommend that you add a general record if there are two records of China Telecom and China Netcom.
Record value: enter an IP address or domain name (not the domain name forwarded by the URL) based on the record type)
Priority: the smaller the number, the higher the priority. The role is: Starting from the server with the highest priority, if the mail server has a problem and the mail cannot be delivered, it will be forwarded to the server with a lower priority. If you don't have many email servers, you don't have to worry about it.
TTL: it is also important. The number is calculated in seconds, and 3600 is an hour. This means that the user requests the resolution of a domain name. After obtaining the IP address, the user will not re-request the resolution from the DNS server within 3600 seconds, and will access the domain name within 3600 seconds, the IP address is directly obtained from the cache of your machine. After 3600 seconds, the system will request the IP address again from the DNS server.

OK. Let's continue. Add a record of China Netcom to make the added record look like the following

At this point, we have successfully added it. Wait for half a minute to test whether it has taken effect.
A. Windows users
Run the nslookup command. First, choose Start> Run-cmd, and press enter to open the command line.
Enter nslookup www.naizhao.com ns1.dnspod.net and wait a moment to see the results returned by the server:
Name: www.naizhao.com

Address: 1.1.1.1
If you are a Netcom user, you will get the following results:
Name: www.naizhao.com

Address: 2.2.2.2
As long as you follow the instructions, there is basically no problem. If the result cannot be returned normally, please wait for two minutes. If it takes two minutes, check whether the record you added is correct.
B. Linux/Unix/Mac users
Directly use the dig command that comes with the system. The dig command is more powerful than nslookup.
Enter dig @ ns1.dnspod.net www.naizhao.com and a large number of results will be returned. We only need to find the following text to prove everything is normal.
; Answer section:
Www.naizhao.com. 3600 in a 1.1.1.1
Netcom users will see
; Answer section:
Www.naizhao.com. 3600 in a 2.2.2.2

So far, DNSPod has been completed, and the next step is to change the DNS server of the domain name to DNSPod.
2. Transfer the DNS of the domain name to DNSPod
Before domain name migration, I will first prompt the risks:

According to the DNS protocol of the domain name, the TTL time of all domain name NS records (that is, records directed to the DNS server) must be 172800 seconds, that is, 48 hours. Based on the knowledge we have learned about TTL, that is, if a domain name is requested once, as long as the cache is not cleared, the NS record will exist for 48 hours. Within 48 hours, any request for this domain name's record is sent to this DNS server. From another perspective, if user A has visited your website and then you modify the DNS server of your domain name in half an hour, then within the remaining 47 and A half hours, user A sends all requests to your domain name to your * old * DNS server, rather than the new server. If user B successfully accesses your website after you modify the DNS, user B will get * New * DNS server address, and all requests will be sent to * New * DNS server, instead of * old *. After understanding this, you will know why it takes 48 hours to change the DNS of the domain name to take effect. You will also understand why record changes to new ones and old ones: this is because your local DNS servers are generally 2-3, however, the records between each of them are not synchronized.
In addition, some very stingy domain name registrars will stop parsing your domain name after you modify the DNS server. In this case, you may risk that users cannot access your site. For such users, I generally recommend that you set the TTL of all your domain name records in the DNS management background of your domain name registrar on the day before the domain name is migrated, change from 3600 to 36000 (10 hours) by default, and change the DNS after, because the DNS record will expire after the user shuts down or disables the adsl modem (of course, it is very likely that old records will be obtained from the DNS of local telecom ). The setting for more than 10 hours allows users to obtain records from the local cache even after the old DNS server stops service.

I will not specifically discuss how to modify DNS. Each domain name registrar is different. Note the following:
1. When entering DNS, remember to remove all the old ones. Do not think that the new and old ones will be stable. This will only give your users an incorrect record.
2. fill in as many DNS servers as possible to make your domain name more stable. DNSPod currently has 6 DNS servers. Generally, you can enter 4 domain name registrars (xinnet). hichina can only enter 2 in the customer panel, but the domain name Management Panel (diy.hichina.com) you can enter all six.

Currently, the six DNS servers in DNSPod are (Note that. net is not. com ):
Ns1.dnspod.net
Ns2.dnspod.net
Ns3.dnspod.net
Ns4.dnspod.net
Ns5.dnspod.net
Ns6.dnspod.net

After a long time, everyone was tired enough. At this time, should ISO be downloaded? A little hard work. I have carved the disk first. In the next chapter, the milk cover will take you to the mysterious Linux Hall.

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.