Author: Linzi

For the Internet, domain name resolution is the first step of access, and this step will often lead to slow access, failure, and even inaccessible, so how to solve these problems? This article will give you a quick start on HTTPDNS and how to resolve LocalDNS exceptions that cause users to access your business incorrectly.

What is DNS

Before explaining HTTPDNS, from the HTTPDNS noun can be seen that it has a certain connection with DNS, so, let’s first introduce DNS.

The Domain Name System (DNS) is a service of the Internet. It is a distributed database of domain names and IP addresses mapped to each other, making it easier for people to access the Internet. The DNS uses UDP port 53. Each level of a domain name contains 63 characters. The total length of a domain name cannot exceed 253 characters.

For example, when a device wants to access another device on the network, it must first obtain its IP address, which is the IP address in TCP/IP. The name system is used to manage the mapping between names and IP addresses because IP addresses are difficult to remember.

Therefore, the domain name is just a convenient name to remember, in fact, the access to network resources or IP address to access, DNS resolution is to resolve the domain name into IP address.

How does DNS work

Since domain name is convenient for users to access the resources on the network, so easy to remember, representative domain name is certainly everyone wants to use the domain name, how to allocate domain name and resolve in the huge network resources?

2.1. Allocation and management of domain names

Domain Names are managed by ICANN (Internet Corporation for Assigned Names and Numbers), which is responsible for domain name system management, IP address allocation, and protocol parameter configuration. As well as the main server system administration and other functions for the establishment of non-profit organizations.

ICANN sets up top-level domains for different countries or regions. These domains usually consist of two English letters. For example,.uk for the United Kingdom,.fr for France, and.jp for Japan. China’s top-level domain name is.cn, and the domain names under.cn are managed by CNNIC (China Internet Network Information Center).

In addition to representing national top-level domains, ICANN originally defined seven top-level domains:.com,.top,.edu,.gov,.mil,.net,.org.

  • .edu for educational institutions
  • .gov for government agencies
  • .mIL is used in the military sector
  • .NET is used for Internet and information centers
  • .org is used by nonprofit organizations

With the development of the Internet, ICANN added two more categories of top-level domain names for a total of seven. .aero,.biz, Coop,.info,.museum,.name, and.pro. Among them,.aero,.coop and.museum are three top-level domains for specific industries or groups, while.biz,.info,.name and.pro are four top-level domains for general use.

  • Aero stands for air transportation
  • .COOP stands for collaborative organization
  • C. museum D. museum
  • Biz means business
  • .name Indicates an individual
  • Pro stands for accountant, lawyer, doctor, etc
  • .info has no specific reference

However, today’s commercial companies generally use.com as their official website by default. At the same time, to avoid malicious registration, usually register other top-level class domain names.

2.2. Composition of domain names

A domain name consists of one or more parts, from right to left: top-level domain name, second-level domain name, third-level domain name… There may not be such a multi-level domain name, but there may be a four-level domain name. Usually, a subdomain is a domain belonging to its parent domain. Such as SOS. State. Oh. Us

2.3. How is a domain name resolved

Detailed DNS resolution process:

  1. The terminal initiates a DNS request to query the IP address of the domain name.
  2. The request first passes through the local parser. The local parser first queries its cache record and returns the result directly if it is in the cache. If no, the Local parser queries the Local DNS Server.
  3. The local DNS server first queries its cache record and returns the result if it has the record in the cache. If no, the local DNS server queries the root DNS server.
  4. The root server returns the TOP-LEVEL DOMAIN name server IP address that can resolve the domain name.
  5. The local DNS server sends DNS requests to the returned TOP-LEVEL domain name server.
  6. After receiving a request, the TOP-LEVEL DNS server does not directly return the mapping between the domain name and the IP address, but returns the authoritative DNS server address that can resolve the domain name
  7. The local DNS server sends A DNS request to the authoritative DNS server for the IP address of the domain name.
  8. After receiving the request, the authoritative DNS server finds the mapping between the domain name and the IP address in its cache table and returns the IP address to the local DNS server.
  9. The local DNS server returns the IP address corresponding to the domain name to the local resolver and stores the mapping in the cache for future use by other users.
  10. The local DNS resolver returns the IP address corresponding to the domain name to the terminal device and stores the mapping in the cache for future use.

2.4. Disadvantages of DNS

From the DNS resolution process, we know the shortcomings of DNS:

  • Domain name cache: The last cache is not necessarily the shortest route
  • Domain forwarding: Domain queries may be cross-carrier
  • Resolution time: DNS query results are obtained only after multiple DNS servers are recursively traversed. There may be some delay.
  • Domain name hijacking: Some domain names may be hijacked or blocked by local carriers.

How to solve the above disadvantages of DNS? HTTPDNS is a solution to these problems.

What is HTTPDNS

By default, the system resolves the domain name into an IP address through the DNS server and sends the network request through the IP address. This DNS resolution process is a black box for App, and developers usually do not pay attention to it. However, because of this, the DNS system of this black box has many shortcomings. How to solve these problems? Can we not use this system, or make the DNS system more intelligent?

In a nutshell, HTTPDNS uses HTTP to request IP addresses from DNS servers, simplifying the complexity of requests. Direct IP access is used when requesting a DNS server. Skip the system resolution process, do your own DNS resolution system.

Advantages of HTTPDNS:

  • Skip LocalDNS to prevent LocalDNS hijacking
  • Direct IP access reduces the average access latency
  • The server algorithm selects the best node IP address to improve the request success rate
  • Quick IP change (not limited by TTL)

HTTPDNS business scenarios

HTTPDNS applies to:

  1. App prevents malicious hijacking
  2. Applications that require high access speed
  3. Application and video acceleration services, together with CDN, return the best node through DNS server to improve access efficiency
  4. Provides more flexible traffic scheduling capabilities

It is mainly applied in the following types of mobile App development:

  • Information and game apps: Hope to reduce access delay, reduce cross-network access, focus on fast response experience.
  • E-commerce APPS: Hope to reduce connection failure rate, improve business work rate, and pay attention to access request stability.
  • Social App: domain name has been hijacked repeatedly, hope users access smoothly.
  • Audio and video apps: High requirements on fluency, improve the connection success rate of music and video playback.

Five, the summary

The HTTPDNS server sends domain name resolution requests to its own DNS server based on HTTP. It avoids domain name hijacking and cross-network access problems caused by the Local DNS. Resolve the problems caused by abnormal domain name resolution in mobile Internet services.

Of course, HTTPDNS seems simple enough, but there’s still a lot to consider if you want to implement an HTTPDNS server yourself. The complete architecture is shown below:

Image source: Tencent Cloud HTTPDNS

QQ is also temporarily the same DNS interference problem. QQ is the same DNS interference problem. For most developers, their own implementation of HTTPDNS is not impossible, but if you want to quickly iterate, now the major cloud services also provide HTTPDNS services, such as HTTPDNS – Ali cloud, HTTPDNS – Tencent cloud, mobile domain name resolution services – Baidu cloud and so on.

In principle, HTTPDNS simply changes the domain name resolution protocol from DNS to HTTP. DNS hijacking (domain name hijacking) is one of the most serious problems. It involves tampering with a web page in some way, inserting advertisements or other content, which is common in the pager era. However, mobile apps mainly cause problems such as unaccessibility and declining success rate. At the same time, in today’s mobile Internet highly mature environment, the user experience is more and more important, intelligent resolution, nearby access, improve the success rate of connection, fast response, ensure smooth user access, these are the advantages of HTTPDNS. The second half of mobile Internet is the ultimate pursuit of user experience, but also the ultimate pursuit of integration and innovation of technology!

Welcome to join us in the comments section

Stay with us for more updates on iOS and industry technology

6. Reference links

  1. Domain name System – Wikipedia
  2. Super detailed DNS protocol parsing – Zhihu
  3. HttpDns in iOS terminal access scheme – digging gold
  4. Comprehensive understanding of DNS and HTTPDNS – nuggets
  5. DNS & HTTPDNS – Digging gold
  6. In-depth understanding of Http requests, DNS hijacking and resolution. – the nuggets
  7. A new idea for global precise traffic scheduling -HttpDNS service details
  8. Httpdns-Aliyun
  9. HttpDNS – Tencent Cloud
  10. Mobile domain name resolution service – Baidu Cloud