Build your own CDN with DNSPod and Squid (ii)

  • 2020-05-09 19:40:41
  • OfStack

Chapter 3 sets up DNS of domain name

Before the big show, let's warm up.
Intelligent DNS can be said to be the basis of CDN. Believe that at ordinary times we do the website will have the following situation: home page put two links, telecom users please visit the main site A, netcom users please visit the mirror site B. Then make two domain names, www.naizhao.com pointing to A, cnc.naizhao.com pointing to B. The user saw along while feel dizzy, random point 1 go in, discover visit speed is really with, estimation whole web page opens, China already entered communist society.
With smart DNS, the above problem can be easily solved. The user only needs to enter www.naizhao.com, the system will automatically determine whether the user is a telecom line or a netcom line, and then automatically return to the telecom or netcom server IP. The whole process is invisible to the user, the user will only feel that brush 1 under the page opened, that is called 1 cool.
Without further ado, let 's do it!

1. Add a domain name to DNSPod
Open www.dnspod.com, and select register from the navigation menu in the upper right corner. After successful registration, return to the home page to log in.
When you log in, you see a box for adding a new domain name. Type naizhao (don't type www). Another example in this article is naizhao.com), then select.com on the right, and click add when done.

After adding, the system will automatically jump to the newly added domain name management page. You can see there's nothing in there. No hurry. Let's take our time.
At the bottom of the page you can see several input boxes and drop-down lists for adding parsing records. Let's try adding a telecom record first. Enter in the following format:
Host record: www
Record type: A
Line type: telecom
Record value: 1.1.1.1
Priority :(blank)
TTL: 3600 (default)
When done, click add.


There are a few places to explain 1:
Host record: that is, the thing in front of the domain name, such as www, then when the record takes effect, www.naizhao.com. If you want to implement naizhao.com (www is missing), leave it blank when you add it, and the system will automatically add an @ to represent the domain name itself.
Record types: A, CNAME and MX. The most commonly used is A, with a record value of 1 IP address. The other thing is MX, which is mail logging, which is used when you're doing mail servers, so I won't go into that.
Line type: more important. If you choose telecom, then the representative of this record * can only * be resolved for telecom users, netcom users are unable to parse out this record. If you only add one telecom record to each domain name, netcom users will not be able to access it. Similarly, the line type of netcom is also 1. There is another point to note: non-netcom, non-eet users will be parsed to the telecom records. That is to say, foreign users, tietong, unicom and other users will be resolved to the telecom server.
There is also a generic, generic meaning that you can parse out this record whether you are a telecom, netcom or any other user. It is not recommended to add a common record when there are two records for telecom and netcom.
Record value: according to the record type, enter 1 IP or 1 domain name (not the domain name forwarded by URL).
Priority: for MX records, the smaller the number, the higher the priority. Effect: start with 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, forget about it.
TTL: again, something important. The Numbers are in seconds, so 3,600 is an hour. This means that if a user requests the resolution of a domain name, he/she will not request a new resolution from the DNS server within 3600 seconds after getting IP. If he/she accesses the domain name within 3600 seconds, he/she will get IP directly from the cache of his/her machine. After 3600 seconds, the DNS server will be re-requested to obtain IP.

OK, let's go ahead and add a netcom record to make it look like this


At this point, we have added successfully. Wait half a minute, let's test 1 to see if it works.
A Windows users
We use the nslookup command, first in the start menu-run-cmd, press enter to open the command line.
Then enter nslookup www.naizhao.com ns1.dnspod.net, wait 1, and see what the server returns:
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 will be no problem. If the results cannot be returned normally, please wait for two minutes. If you can't wait two minutes, check to see if you've added the correct record.
B Linux/Unix/Mac users
Use the dig command that comes with the system directly. The dig command is more powerful than nslookup.
Enter dig @ns1.dnspod.net www.naizhao.com, and you will get back a bunch of results. We only need to find the following text to prove that 1 tangent is normal
;; ANSWER SECTION:
www.naizhao.com.             3600     IN         A         1.1.1.1
Netcom users will see it
;; ANSWER SECTION:
www.naizhao.com.             3600     IN         A         2.2.2.2

At this point, work on DNSPod has been completed. The next step is to change the DNS server to DNSPod.
2. Transfer DNS of domain name to DNSPod
Before the transfer of domain name, I would like to first remind you of the following risks:

According to the DNS protocol for domain names, the NS record (that is, the record pointing to the DNS server) for all domain names must have an TTL time of 172,800 seconds, or 48 hours. Based on what we learned earlier about TTL, that is, if a domain name is requested once, the NS record will exist for 48 hours as long as the cache is not cleared. Within 48 hours, any request for records for this domain name will be sent to this DNS server. To put it another way, if an A user visits your site and you change the DNS server for your domain name half an hour later, then all requests for your domain name from an A user will be sent to your * old *DNS server instead of the new server for the remaining 47 and a half hours. B users visit your site after you successfully modify DNS, then B users will get * new *DNS server address and all requests will be sent to * new *DNS server instead of * old *. Once you understand this, then you will know why it takes 48 hours to change the DNS of a domain name to take effect. You'll also understand why records 1 go new and 1 goes old: this is because your local DNS server 1 is like two or three, but the records are not in sync with each other.
In addition, some very stingy domain name registrars will stop resolving your domain name after you modify the DNS server. You run the risk that users won't be able to access your site. As advice to the user, I 1 1 day before the migration domain, in your domain registrar DNS management background, put all your domain name record TTL, changed from the default of 3600 to 36000 (more than 10 hours), and choose modify DNS after 10 o 'clock in the evening, because DNS record will be closed down user shutdown, ADSL MODEM after failure (of course, will very likely from the local telecom DNS old record). The 10 + hour setup allows users to get records from the local cache even after the old DNS server is out of service.

I won't go into the details of how to modify DNS, but every domain registrar is different. A few things to note:
1. When filling in DNS, be sure to remove all the old ones. Don't assume that keeping the old ones will keep them stable.
2. Fill in the DNS server as often as possible to make your domain name more stable. Currently, DNSPod has 6 DNS servers. The 1-like domain name registrar allows you to fill in 4 (new web). Wanwan can only fill in 2 in the client panel, but you can fill in all 6 in the domain name management panel (diy.hichina.com).


Currently, the six DNS servers of DNSPod are:
ns1.dnspod.net
ns2.dnspod.net
ns3.dnspod.net
ns4.dnspod.net
ns5.dnspod.net
ns6.dnspod.net


After a long time, everyone is tired. At this point, ISO should be downloaded, right? Hard 1 point, the first to carve the plate. In the next chapter, the bra will take you to the mysterious Linux palace.

Related articles: