How does Android perform DNS resolution?

Source: Internet
Author: User
Tags dns2

In ubuntu and other Linux systems, domain names are resolved through the resolve. conf file. You can view the following through man resolve. conf:

 

The resolver is a set of routines in the C library that provide access to the Internet Domain Name System (DNS ). the resolver configuration file contains information that is read by the resolver routines the first time they are invoked by a process. the file is designed to be human readable and contains a list of keywords with values that provide varous types of resolver information. if this file doesn' t exist the only name server to be queried will be on the local machine; the domain name is determined from the hostname and the domain search path is constructed from the domain name.

 

Therefore, DNS resolution is performed by C-library functions. In the bionic/libc/docs/overview.txt file of Android, we can also see:

NS resolver:
Bionic uses a NetBSD-derived resolver library which has been modified in the following ways:
-Don't implement the name-server-Switch feature (a.k. A. <nsswitch. h>)
-Read/system/etc/resolv. conf instead of/etc/resolv. conf
-Read the list of servers from system properties. the code looks for 'Net. dns1 ', 'Net. dns2 ', Etc .. each property shoshould contain the IP address of a DNS server.
These properties are set/modified by other parts of the Android system (e.g. The DHCPD Daemon ).
The implementation also supports per-process DNS Server LIST, using the properties 'Net. dns1. <pid> ', 'Net. dns2. <pid> ', Etc... where <pid> stands for the numerical ID of the current process.
-When implements Ming a query, use a properly randomized query ID (instead of a incremented one), for increased security.
-When Ming a query, bind the local client socket to a random port for increased security.
-Get rid of * unique * unfortunate thread-safety issues in the original code
Bionic does ** not * expose implementation details of its DNS resolver; the content of <ARPA/nameser. h> is intentionally blank. The resolver implementation might change completely in the future.

Therefore, Android focuses on attributes such as resolv. conf and net. dns1.

 

You can use getprop in the ADB shell to view the attributes. net. dns1, net. dns2 and net. tiwlan0.dns1 and net. tiwlan0.dns2, net. rmnet0.dns1 and net. rmnet0.dns2 and other attributes.

 

Related Article

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.