2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
DNS Resolver
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
DNS リゾルバ モジュールは、DNS 傍受や設定の更新攻撃からユーザーを保護し、DNS 解決のネットワーク パフォーマンスを改善します。このモジュールには、名前(www.google.com など)を IP アドレス(2001:db8::1 など)に変換する DNS スタブリゾルバを実装するためのコードが含まれています。DNS スタブリゾルバは、InetAddress#getAllByName、Network#getAllByName などの Java API 要素、およびネイティブ ネットワーク機能をサポートし、DNS クエリを送受信して結果をキャッシュします。
Android 10 の変更点
Android 9 以下を搭載するデバイスでは、DNS リゾルバコードは Bionic と netd
で配布されます。DNS ルックアップは、システムレベルのキャッシュのために netd
デーモンに集中化され、アプリは Bionic の関数(getaddrinfo
など)を呼び出します。クエリは /dev/socket/dnsproxyd
の UNIX ソケットを介して netd
デーモンに送信されます。このデーモンはリクエストを解析し、getaddrinfo
を再度呼び出して DNS ルックアップを発行し、他のアプリが使用できるように結果をキャッシュします。DNS リゾルバの実装は、大部分が bionic/libc/dns/
に含まれ、一部は system/netd/server/dns
に含まれています。
Android 10 では DNS リゾルバコードが system/netd/resolv,
に移動され、C++ への変換、モダナイズおよびリファクタリングが行われています。Bionic のコードはアプリの互換性を維持するために残されていますが、システムから呼び出されることはありません。次のソースパスは、リファクタリングの影響を受けます。
bionic/libc/dns
system/netd/client
system/netd/server/dns
system/netd/server/DnsProxyListener
system/netd/server/ResolverController
system/netd/resolv
DNS リゾルバ モジュール(com.android.resolv)は、APEX ファイルとして提供され、netd
によって動的にリンクされます。しかし、モジュールがローカル ソケット /dev/socket/dnsproxyd
を直接提供するため、netd
には依存関係はありません。リゾルバ構成の Binder エンドポイントは、netd
からリゾルバに移動されました。つまり、システム サービスは netd
を経由せずにリゾルバ モジュールを直接呼び出すことができます。
DNS リゾルバ モジュールは libc
(Bionic)に依存し、その依存関係を静的にリンクします。他のライブラリは必要ありません。
mDNS の .local 解決
2021 年 11 月以降、Android リゾルバが mDNS の .local 解決に対応するようになりました。これは、RFC 6762 の「5.1 One-Shot multicast DNS Queries」を実装したもので、標準の DNS クエリを 224.0.0.251:5353 または [FF02::FB]:5353 に送信します。mDNS の解決は、ホスト名の末尾を *.local
にして getaddrinfo()
を呼び出すことで、透過的にサポートされます。
mDNS の .local 解決により、getaddrinfo()
の既存のアドレス取得機能が拡張されます。デバイスで mDNS の .local 解決がサポートされている場合、getaddrinfo()
API は mDNS クエリを 224.0.0.251:5353 または [FF02::FB]:5353 に送信し、ローカル アドレスを返します。デバイスで mDNS の .local 解決がサポートされていない場合、getaddrinfo()
API メソッドは DNS クエリを DNS サーバーに送信します。
このコードは AOSP のものであり、packages/modules/DnsResolver
にあります。現在の mDNS の設計でアドレスを取得し続けることも、getaddrinfo()
を使用することも可能です。この機能の動作は、おおまかには、通常の DNS クエリを mDNS のマルチキャスト アドレスに送信するというものです。この機能がシステムの健全性に影響することはありません。
ユーザーは「adb shell ping6 HOSTNAME.local
」というコマンドを使用できます。ここでの HOSTNAME は、LAN 上のターゲット デバイスのホスト名です(例: adb shell ping6 ipad.local
)。
VPN 接続とモバイルデータ接続は .local 解決の対象とはなりません。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# DNS Resolver\n\nThe DNS Resolver module provides user protection for DNS interception\nand configuration update attacks and improved network performance for DNS\nresolutions. The module contains the code that implements the DNS stub\nresolver, which translates names such as **www.google.com** to IP\naddresses such as **2001:db8::1** . The DNS stub resolver backs\nJava API elements such as\n[InetAddress#getAllByName](https://developer.android.com/reference/java/net/InetAddress#getAllByName(java.lang.String)) and\n[Network#getAllByName](https://developer.android.com/reference/android/net/Network#getAllByName(java.lang.String)), as well as\n[native networking functions](https://developer.android.com/ndk/reference/group/networking), and implements sending and\nreceiving DNS queries and caching the results.\n\nChanges in Android 10\n---------------------\n\n\nOn devices running Android 9 and lower, the DNS resolver code is spread across\nBionic and `netd`. DNS lookups are centralized in the\n`netd` daemon to allow for system-wide caching, while apps\ncall functions (such as `getaddrinfo`) in Bionic. The query is sent\nover a UNIX socket to `/dev/socket/dnsproxyd` to the\n`netd` daemon, which parses the request and calls\n`getaddrinfo` again to issue DNS lookups, then caches the results\nso that other apps can use them. The DNS resolver implementation was mostly\ncontained in `bionic/libc/dns/` and partly in\n`system/netd/server/dns`.\n\n\nAndroid 10 moves the DNS resolver code to\n`system/netd/resolv,` converts it to C++, then modernizes and\nrefactors the code. The code in Bionic continues to exist for app\ncompatibility reasons, but is no longer called by the system. These source\npaths are affected by the refactoring:\n\n- `bionic/libc/dns`\n- `system/netd/client`\n- `system/netd/server/dns`\n- `system/netd/server/DnsProxyListener`\n- `system/netd/server/ResolverController`\n- `system/netd/resolv`\n\nFormat and dependencies\n-----------------------\n\n\nThe DNS Resolver module (\\`com.android.resolv\\`) is delivered as an\n[APEX](/docs/core/ota/apex) file and is dynamically linked by\n`netd`; however, `netd` is **not** a\ndependency as the module serves the local socket\n`/dev/socket/dnsproxyd` directly. The Binder endpoint for the\nresolver configuration was moved from `netd` to the resolver,\nmeaning that the system service can call directly into the resolver module\nwithout going through `netd`.\n\n\nThe DNS Resolver module depends on `libc` (Bionic) and\nstatically links its dependencies; no other libraries are required.\n\nmDNS .local resolution\n----------------------\n\nStarting from November 2021, Android resolver supports mDNS .local resolution, which implements\n\"5.1 One-Shot multicast DNS Queries\" in RFC 6762 to send standard DNS queries blindly to\n224.0.0.251:5353 or \\[FF02::FB\\]:5353. mDNS resolution is transparently supported\nby calling `getaddrinfo()` with a hostname ending in `*.local`.\n\nmDNS .local resolution augments the existing functionality of `getaddrinfo()`\nto get the addresses. If a device supports mDNS .local resolution, then the\n`getaddrinfo()` API sends mDNS queries to 224.0.0.251:5353 or \\[FF02::FB\\]:5353\nand returns the local addresses. If a device doesn't support mDNS .local\nresolution, then the `getaddrinfo()` API method sends a DNS query to the DNS\nserver.\n\nThe code is in AOSP, located in `packages/modules/DnsResolver`. Users can keep their\ncurrent mDNS design to get the addresses, or use `getaddrinfo()` instead. The behavior of\nthis feature is like a regular DNS query sent to the mDNS multicast addresses. This feature has no\nimpact on system health.\n\nUsers can use the command `adb shell ping6 `\u003cvar translate=\"no\"\u003eHOSTNAME\u003c/var\u003e`.local`,\nwhere \u003cvar translate=\"no\"\u003eHOSTNAME\u003c/var\u003e is the hostname of a target device on the LAN, for example,\n`adb shell ping6 ipad.local`.\n\nVPN and mobile data connections are excluded from .local resolution."]]