Create your own CDN with DNSPod and Squid

  • 2020-05-06 12:11:40
  • OfStack

Chapter 3 sets up the DNS
domain name
Let's warm up before the big game starts.
Smart 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 to A, cnc.naizhao.com to B. The user looked along while feel dizzy, random point a go in, discover visit speed is really with, estimation whole web page opens, China already entered communist society.
With the smart DNS, the above problems are easily solved. Just type www.naizhao.com, and the system will automatically determine whether the user is a telecommunication 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 a brush on the web page opened, that called a cool.
Without further ado, let's do it!

1. Add the domain name
above 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 login.
When you log in, you see a box for adding a new domain name. Type naizhao (don't type www). The other example in this article is naizhao.com), then select.com on the right, and click add.

After adding, the system will automatically jump to the newly added domain name management page. You can see there's nothing in it. No hurry. Let's take our time.
At the bottom of the page you can see several input fields and a drop-down list for new parsing records. Let's try to add 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 :(left blank)
TTL: 3600 (default)
When done, click add.


There are a few places to explain:
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 (there is no www), leave it blank when you add it, and the system will automatically add an @ to represent the domain name itself.
Record types: A, CNAME, MX. The most common is A, and the record value is an IP address. The other thing is MX, which is mail logging, which is used when you're doing mail servers, and I won't go into that.
Line type: more important. If you choose telecom, then on behalf of this record * can only * to the telecom users out of the analysis, netcom users are unable to parse out this record. If you add only one telecom record to a domain name, netcom users will not be able to access it. The same goes for the type of network connection. There is another point to be made: non-netcom, non-edunet users will be parsed to the telecom records. In other words, foreign users, tietong, unicom and other users will be resolved to the telecom server.
There is also a general, general meaning, whether you are telecom or netcom or other users, you can parse out this record. In the presence of telecom and netcom records, it is not recommended to add a common record.
Record value: enter an IP or a domain name (not the domain name forwarded by URL)
, depending on the record type Priority: in MX records, the smaller the number, the higher the priority. 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 the lower priority. If you don't have many email servers, forget it.
TTL: the same important thing. The Numbers are in seconds, so 3,600 is an hour. This means that if a user requests a domain name to be resolved, the DNS server will not be re-resolved within 3600 seconds after IP is obtained. If the user accesses the domain name within 3600 seconds, IP will be retrieved directly from the cache of his machine. If you exceed 3600 seconds, you will ask the DNS server again for IP.

OK, let's go ahead and add a netcom record so that the finished record looks like this

At this point, we have added successfully. Wait half a minute, and we'll see if it works.
A.
Windows users We use the nslookup command, first from the start menu - run -cmd, press enter to open the command line.
Then type nslookup www.naizhao.com ns1.dnspod.net, wait a moment 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 result
Name:     www.naizhao.com

Address:     2.2.2.2
As long as you follow the instructions, there are few problems. 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. The dig command is more powerful than nslookup.
Enter dig @ns1.dnspod.net www.naizhao.com, and a whole bunch of results will be returned. We just need to find the text below to prove that everything is ok ;; 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

Now that work on DNSPod is complete, the next step is to change the DNS server to DNSPod.
2. Transfer the domain name DNS to DNSPod
Before domain name migration, let me give you an indication of the risk:

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 a record of this domain name is 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 in the remaining 47 and a half hours, all requests from A users for your domain name will be sent to your * old *DNS server, not the new one. B users visit your site after you successfully modify DNS, then B users will get * new *DNS server address, all requests will be sent to * new *DNS server, not * old *. Once you understand this, then you will see why it takes 48 hours for the domain name DNS to be changed to take effect. You can also see why records become new and old: this is because your DNS servers typically have two or three, but the records are not synchronized between them.
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. To such user, I usually suggest the 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 get old records from local telecom DNS). Setting up to 10 hours or more 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. Every domain registrar is different. A few things to note: the
1. When filling in DNS, be sure to remove all the old ones. Don't assume that the old ones will be stable and that your users will get the wrong records.
2. Fill in the DNS server as often as possible to make your domain name more stable. Currently DNSPod has 6 DNS servers, general domain name registrar allows you to fill in 4 (new network), wanwang can only fill in 2 in the customer panel, but in the domain name management panel (diy.hichina.com) can fill in 6.


Currently, the six DNS servers in DNSPod are (note that it is.net, 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 is tired. At this point, ISO should be downloaded, right? A little hard, the first plate to carve good. In the next chapter, the bra will take you to the mysterious Linux palace.

Related articles: