KDOC 510: DNSサーバでテストTDLを使用する例を示す

この文書のステータス

  • 作成
    • 2025-12-23 貴島
  • レビュー
    • 2026-01-08 貴島

概要

.test は特別なTDLで、使われないことが保証されているので、アプリケーションの内部用として自由に使える。

To safely satisfy these needs, four domain names are reserved as listed and described below.

.test .example .invalid .localhost

“.test” is recommended for use in testing of current or new DNS related code.

RFC2606

.test はとくにDNS関係のコードのテストに使用するのを推奨している。テスト用ドメインを使えることがどういうケースに役立つかを、AdGuardHomeのコードで示す。

たとえば、DNSサーバ自身のヘルスチェックで使っている。

// healthcheckFQDN is a reserved domain-name used for healthchecking.
//
// [Section 6.2 of RFC 6761] states that DNS Registries/Registrars must not
// grant requests to register test names in the normal way to any person or
// entity, making domain names under the .test TLD free to use in internal
// purposes.
//
// [Section 6.2 of RFC 6761]: https://www.rfc-editor.org/rfc/rfc6761.html#section-6.2
const healthcheckFQDN = "healthcheck.adguardhome.test."

どう使われているか見る。

if q.Name == healthcheckFQDN {
	// Generate a NODATA negative response to make nslookup exit with 0.
	pctx.Res = s.replyCompressed(pctx.Req)

	return resultCodeFinish
}

ヘルスチェックドメイン名のときは上位ネームサーバに解決しようとせずに、DNSサーバの生存を示す空のデータを返す。 .test は使われないことが保証されているので、こういうことができる。

関連

なし。