RESOLV.CONF

Section: Linux Programmer's Manual (5)
Updated: 2020-08-13
Index JM Home Page
 

名前

resolv.conf - レゾルバ設定ファイル  

書式

/etc/resolv.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 various types of resolver information. The configuration file is considered a trusted source of DNS information; see the trust-ad option below for details.

If this file does not exist, only the name server on the local machine will be queried, and the search list contains the local domain name determined from the hostname.

この状態を変更するための設定オプションには、以下のようなものがある。

nameserver ネームサーバの IP アドレス
レゾルバが問い合わせをするネームサーバのインターネットアドレス。 アドレスには IPv4 アドレスか IPv6 アドレスを指定する。 IPv4 アドレスはドット表記で、 IPv6 アドレスは RFC 2373 で定められたコロン表記 (おそらくドット表記も可) で指定する。 このキーワード 1 つごとに 1 台づつ、 MAXNS 台 (現状では 3 台、<resolv.h> を参照) までのネームサーバをリストできる。 複数のサーバが指定された場合、レゾルバライブラリは リストされた順に問い合わせを行う。 nameserver エントリーがない場合、 デフォルトではローカルマシン上のネームサーバが使われる。 (ここで使われるアルゴリズムは以下のようなものである。 はじめにネームサーバに問い合わせを試みる。 この問い合わせがタイムアウトになった場合、 次のネームサーバに問い合わせを試みる。 これをネームサーバがなくなるまで続ける。 それでも応答がない場合は、リトライ最大回数に達するまで 全てのネームサーバに問い合わせを繰り返す。)
search ホスト名ルックアップのための検索リスト
By default, the search list contains one entry, the local domain name. It is determined from the local hostname returned by gethostname(2); the local domain name is taken to be everything after the first '.'. Finally, if the hostname does not contain a '.', the root domain is assumed as the local domain name.
これを変更するには、search キーワードの後に 希望するドメイン検索パスをスペースまたはタブで区切ってリストすればよい。 ドットの数が ndots (デフォルトでは 1) より少ないレゾルバの問い合わせは、 一致するものが見つかるまで検索パスの各要素を順に使って試す。 複数のサブドメインを持つ環境では、 第三者による攻撃 (man-in-the-middle attack) と ルート DNS サーバへの不必要なトラフィックを避けるために、 以下の options ndots:n を読んでほしい。 このプロセスは遅く、リストされたドメインがローカルのものでない場合、 多大なネットワークトラフィックを発生させることに注意すること。 さらに、これらのドメインのいずれかひとつにでも適切なサーバがない場合、 問い合わせがタイムアウトになる点にも注意すること。
If there are multiple search directives, only the search list from the last instance is used.
In glibc 2.25 and earlier, the search list is limited to six domains with a total of 256 characters. Since glibc 2.26, the search list is unlimited.
The domain directive is an obsolete name for the search directive that handles one search list entry only.
sortlist
このオプションを使うと、 gethostbyname(3) で返されるアドレスをソートさせることができる。 sortlist は IP アドレスとネットマスクのペアで指定される。 ネットマスクは省略可能であり、 デフォルトではネットに対するデフォルトのネットマスクである。 IP アドレスとオプションのネットマスクのペアはスラッシュで区切る。 最大 10 組のペアを指定できる。 以下に例を示す。
sortlist 130.155.160.0/255.255.240.0 130.155.0.0
options
options により、レゾルバの内部変数を変更することができる。 書式は以下の通りである。
options option ...

ここで option は次のうちのいずれかである。

debug
RES_DEBUG_res.options にセットする (glibc がデバッグを有効にしてコンパイルされている場合にのみ有効である; resolver(3) を参照)。
ndots:n
最初の完全な名前での問い合わせが実行される前に、 res_query(3) (resolver(3) を参照) に与えられる名前に含まれているべきドットの数の閾値」を設定する。 n のデフォルトは 1 である。 これは、名前にドットがある場合、search list の要素が付加される前に、 その名前が完全な名前として最初に試されるということを意味している。 このオプションの値の上限は 15 であり、黙ってこの値まで切り詰められる。
timeout:n
Sets the amount of time the resolver will wait for a response from a remote name server before retrying the query via a different name server. This may not be the total time taken by any resolver API call and there is no guarantee that a single resolver API call maps to a single timeout. Measured in seconds, the default is RES_TIMEOUT (currently 5, see <resolv.h>). The value for this option is silently capped to 30.
attempts:n
「レゾルバが諦めて呼び出し元のアプリケーションにエラーを返すまでに、 ネームサーバに問い合わせを行う回数」を設定する。 デフォルトは RES_DFLRETRY 回である (現状では 2 回、<resolv.h> を参照)。 このオプションの値の上限は 5 であり、黙ってこの値まで切り詰められる。
rotate
_res.options に RES_ROTATE を設定する。リストされているネームサーバから選ぶときに、ラウンドロビン (round-robin) 選択を行わせる。リストされている全てのサーバで問い合わせの負荷を分散する効果があり、最初にリストされたサーバに全てのクライアントが毎回最初に問い合わせを行うわけではなくなる。
no-check-names
_res.optionsRES_NOCHECKNAME を設定する。 入ってくるホスト名とメールアドレスに、 アンダースコア (_)・ASCII 以外の文字・制御文字といった 不正な文字が含まれていないかを調べる 最近の BIND のチェックを無効にする。
inet6
Sets RES_USE_INET6 in _res.options. This has the effect of trying an AAAA query before an A query inside the gethostbyname(3) function, and of mapping IPv4 responses in IPv6 "tunneled form" if no AAAA records are found but an A record set exists. Since glibc 2.25, this option is deprecated; applications should use getaddrinfo(3), rather than gethostbyname(3).
ip6-bytestring (glibc 2.3.4 から 2.24 まで)
Sets RES_USEBSTRING in _res.options. This causes reverse IPv6 lookups to be made using the bit-label format described in RFC 2673; if this option is not set (which is the default), then nibble format is used. This option was removed in glibc 2.25, since it relied on a backward-incompatible DNS extension that was never deployed on the Internet.
ip6-dotint/no-ip6-dotint (glibc 2.3.4 から 2.24 まで)
Clear/set RES_NOIP6DOTINT in _res.options. When this option is clear (ip6-dotint), reverse IPv6 lookups are made in the (deprecated) ip6.int zone; when this option is set (no-ip6-dotint), reverse IPv6 lookups are made in the ip6.arpa zone by default. These options are available in glibc versions up to 2.24, where no-ip6-dotint is the default. Since ip6-dotint support long ago ceased to be available on the Internet, these options were removed in glibc 2.25.
edns0 (glibc 2.6 以降)
_res.optionsRES_USE_EDNSO をセットする。これにより、RFC 2671 で規定されている DNS 拡張のサポートが有効になる。
single-request (glibc 2.10 以降)
_res.optionsRES_SNGLKUP をセットする。 glibc バージョン 2.9 以降では、 glibc はデフォルトでは IPv4 と IPv6 の検索を並行して実行する。 アプライアンス DNS サーバの中には、このような問い合わせを 適切に処理できず、検索要求がタイムアウトになってしまう。 このオプションをセットすると、このデフォルトの動作が無効になり、 glibc は IPv6 と IPv4 の検索を順番に実行するようになる (名前解決処理が若干遅くなるというデメリットがある)。
single-request-reopen (glibc 2.9 以降)
_res.optionsRES_SNGLKUPREOP をセットする。リゾルバは同じソケットを使って A レコードと AAAA レコードの検索要求を行う。 いくつかのハードウェアは実装が間違っており、応答を一つしか返さない。 この状況になると、クライアントシステムは 2 番目の応答を待ち続けてしまう。 このオプションを有効にすると、この動作が変更され、 同じポートからの 2 つの検索要求が正しく処理されなかった場合、 2 番目の検索要求を送信する前にソケットをクローズし 新しいソケットをオープンするようになる。
no-tld-query (glibc 2.14 以降)
RES_NOTLDQUERY を _res.options にセットする。 このオプションを設定すると、 res_nsearch() が完全なドメイン名ではない名前のトップレベルドメイン (TLD) としての検索を行わなくなる。 これにより、localhost に検索リストの要素をつけるのではなく、``localhost'' を TLD として設定しているようなサイトでは問題が起こる可能性がある。 RES_DEFNAMES も RES_DNSRCH もセットされていない場合には、このオプションは効果はない。
use-vc (glibc 2.14 以降)
Sets RES_USEVC in _res.options. This option forces the use of TCP for DNS resolutions.
no-reload (glibc 2.26 以降)
Sets RES_NORELOAD in _res.options. This option disables automatic reloading of a changed configuration file.
trust-ad (glibc 2.31 以降)
Sets RES_TRUSTAD in _res.options. This option controls the AD bit behavior of the stub resolver. If a validating resolver sets the AD bit in a response, it indicates that the data in the response was verified according to the DNSSEC protocol. In order to rely on the AD bit, the local system has to trust both the DNSSEC-validating resolver and the network path to it, which is why an explicit opt-in is required. If the trust-ad option is active, the stub resolver sets the AD bit in outgoing DNS queries (to enable AD bit support), and preserves the AD bit in responses. Without this option, the AD bit is not set in queries, and it is always removed from responses before they are returned to the application. This means that applications can trust the AD bit in responses if the trust-ad option has been set correctly.
In glibc version 2.30 and earlier, the AD is not set automatically in queries, and is passed through unchanged to applications in responses.

システムの resolv.conf ファイルにある search キーワードは、 スペースで区切った検索ドメインのリストを 環境変数 LOCALDOMAIN に設定することにより、各プロセス毎に上書きすることができる。

システムの resolv.conf ファイルにある options キーワードは、 上の options セクションで説明したように、 スペースで区切ったレゾルバオプションのリストを 環境変数 RES_OPTIONS に設定することにより、各プロセス毎に修正することができる。

キーワードと値は同じ行に書かなければならない。 また、(nameserver のような) キーワードが行の先頭になければならない。 値はキーワードの後にスペースで区切って続ける。

セミコロン (;) かハッシュ文字 (#) で始まる行はコメントとして扱われる。  

ファイル

/etc/resolv.conf, <resolv.h>  

関連項目

gethostbyname(3), resolver(3), host.conf(5), hosts(5), nsswitch.conf(5), hostname(7), named(8)

BIND のネームサーバオペレーションガイド  

この文書について

この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

関連キーワード

RES, サーバ, option, resolver, 問い合わせ, search, リスト, 検索, ネーム, アドレス

Linux マニュアル 一覧

[man1] [man2] [man3] [man4] [man5] [man6] [man7] [man8]
[a] [b] [c] [d] [e] [f] [g] [h] [i] [j] [k] [l] [m] [n] [o] [p] [q] [r] [s] [t] [u] [v] [w] [x] [y] [z]

 

Index

名前
書式
説明
ファイル
関連項目
この文書について

This document was created by man2html, using the manual pages.
Time: 12:08:52 GMT, June 11, 2022