1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Cloudflare と NS1 を使って Multi-signer DNSSEC を構成する

Last updated at Posted at 2023-10-31

参考:DNSSEC

Multi-signer DNSSEC とは

複数のプロバイダで同時に DNSSEC 対応することです。
例えば、以下のマルチプライマリ構成では、ネームサーバー・NS レコードに複数のプロバイダを登録します。

要件

以下の RFC にある通り、複数のプロバイダで DNSSEC に対応(Zone apex に DNSKEY 登録)できることが必要です。

  • RFC 8901: Multi-Signer DNSSEC Models
    The central requirement for both of the multiple-signer models (Section 2.1) is to ensure that the ZSKs from all providers are present in each provider's apex DNSKEY RRset and vouched for by either the single KSK (in Model 1) or each provider's KSK (in Model 2.)

構成パターン

以下の2つが考えられます。
どちらのパターンでも、ZSK を相互にクロスインポートすることが必要です。

モデル1:KSK をプロバイダ共通のものとする

モデル2:KSK をプロバイダ別に分ける

KSK を複数登録する代わりに、1つの Combined Signing Keys (CSK) を使う方法もあります。

Model 2
Figure 4 — Model 2 cross-imports ZSKs across providers and publishes the DS corresponding to each of their KSKs in the parent DS RRset.

DNSSEC を無停止で移行するには

DNSSEC が有効なドメインを無停止で移行するには、モデル2(プロバイダ毎に固有のKSKとZSK)を過渡期の構成として使うことで実現できます。

  • Multi-Signer DNSSEC models | APNIC Blog
    Importantly, non-disruptively transferring a DNSSEC signed zone from one DNS operator to another operator can be accommodated by Model 2 (Unique KSK and ZSK per provider). In fact, operator handoff is just a transitional state of a Model 2 Multi-Signer configuration.

Cloudflare と NS1 を使った Multi-signer DNSSEC

モデル2を使った構成になります。
レジストラには、Value Domain を使います。

セットアップ

以下のドキュメントに従って、実装します。

このような Multi-Provider セットアップにおけるゾーンのアクティベーションには、Enterprise Plan が必要です

DNSSEC 有効化

Cloudflare

通常通り、Primary DNS として Cloudflare を権威 DNS とするようにゾーン登録します。

以下の API 操作で Multi-signer DNSSEC を有効化します。

export EMAIL='YOUR_EMAIL'
export APIKEY='YOUR_APIKEY'
export ZONE_ID='YOUR_ZONE_ID'

curl --request PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dnssec" \
--header "X-Auth-Email: $EMAIL" \
--header "X-Auth-Key: $APIKEY" \
--header 'Content-Type: application/json' \
--data '{
  "status": "active",
  "dnssec_multi_signer": true
}'

"dnssec_status": "pending" は「DNSSECは有効になっていますが、レジストラでCloudflare DSレコードが追加されていない」という意味です。

result.json
{
  "result": {
    "dnssec_status": "pending",
    "dnssec_enabled": true,
    "dnssec_multi_signer": true
  },
  "success": true,
  "errors": [],
  "messages": []
}

NS1

以下のリンクからフリーアカウントを作成できます。

NS1 を Primary DNS として設定し、DNSSEC を有効化します。

image.png

ZSK クロスインポート・NS レコード設定

Cloudflare

ZSK クロスインポート

NS1 から取得できる以下の Public Key (NS1 ZSK) を Cloudflare に設定します。

flags の値が 257 なら KSK、 256 なら ZSK です。

image.png

curl --request POST "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records" \
--header "X-Auth-Email: $EMAIL" \
--header "X-Auth-Key: $APIKEY" \
--header 'Content-Type: application/json' \
--data '{
  "type": "DNSKEY",
  "name": "<ZONE_NAME>",
  "data": {
    "flags": 256,
    "protocol": 3,
    "algorithm": 13,
    "public_key": "<PUBLIC_KEY>"
  },
  "ttl": 3600
}'
result.json
{
  "result": {
    "id": "xxx",
    "zone_id": "xxx",
    "zone_name": "example.com",
    "name": "example.com",
    "type": "DNSKEY",
    "content": "256 3 13 xxx",
    "proxiable": false,
    "proxied": false,
    "ttl": 3600,
    "locked": false,
    "data": {
      "algorithm": 13,
      "flags": 256,
      "protocol": 3,
      "public_key": "xxx"
    },
    "meta": {
      "auto_added": false,
      "managed_by_apps": false,
      "managed_by_argo_tunnel": false,
      "source": "primary"
    },
    "comment": null,
    "tags": [],
    "created_on": "2023-10-31T02:11:10.060349Z",
    "modified_on": "2023-10-31T02:11:10.060349Z"
  },
  "success": true,
  "errors": [],
  "messages": []
}

NS レコード設定

NS1 から取得できる以下の Nameserver を Cloudflare で NS レコードに設定します。

image.png

curl --request POST "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records" \
--header "X-Auth-Email: $EMAIL" \
--header "X-Auth-Key: $APIKEY" \
--header 'Content-Type: application/json' \
--data '{
  "type": "NS",
  "name": "<ZONE_NAME>",
  "content": "dns2.p09.nsone.net",
  "ttl": 86400
}'
result.json
{
  "result": {
    "id": "xxx",
    "zone_id": "xxx",
    "zone_name": "example.com",
    "name": "example.com",
    "type": "NS",
    "content": "dns2.p09.nsone.net",
    "proxiable": false,
    "proxied": false,
    "ttl": 86400,
    "locked": false,
    "meta": {
      "auto_added": false,
      "managed_by_apps": false,
      "managed_by_argo_tunnel": false,
      "source": "primary"
    },
    "comment": null,
    "tags": [],
    "created_on": "2023-10-31T02:25:44.9506Z",
    "modified_on": "2023-10-31T02:25:44.9506Z"
  },
  "success": true,
  "errors": [],
  "messages": []
}

use_apex_ns を有効化します。

This step is required if you are using Cloudflare as a primary DNS provider - without enabling this setting, DNS queries to the zone apex requesting NS records will be responded with Cloudflare nameservers.

curl --request PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_settings/use_apex_ns" \
--header "X-Auth-Email: $EMAIL" \
--header "X-Auth-Key: $APIKEY" \
--header 'Content-Type: application/json' \
--data '{
  "id": "use_apex_ns",
  "value": true
}'
result.json
{
  "result": [
    {
      "id": "use_apex_ns",
      "value": true
    }
  ],
  "success": true,
  "errors": [],
  "messages": []
}

NS1

ZSK クロスインポート

Cloudflare から取得できる以下の Public Key (Cloudflare ZSK) を NS1 に設定します。

curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dnssec/zsk" \
--header "X-Auth-Email: $EMAIL" \
--header "X-Auth-Key: $APIKEY"
cloudflare_zsk.json
{
  "result": [
    {
      "Hdr": {
        "Name": "example.com.",
        "Rrtype": 48,
        "Class": 1,
        "Ttl": 3600,
        "Rdlength": 0
      },
      "Flags": 256,
      "Protocol": 3,
      "Algorithm": 13,
      "PublicKey": "xxx"
    }
  ],
  "success": true,
  "errors": [],
  "messages": []
}

API 操作が必要なため、API KEY を発行します。

image.png

以下のコマンドでインポートできます。

export NSONE_API_KEY='YOUR_NSONE_API_KEY'
export ZONE_NAME='YOUR_ZONE_NAME'

curl -X PUT -H "X-NSONE-Key: $NSONE_API_KEY" https://api.nsone.net/v1/zones/$ZONE_NAME/dnssec/external_keys/cloudflare -d '{
    "dnskey": {
        "ttl": 1200,
        "data": [
            {
                "flags": 256,
                "protocol": 3,
                "algorithm": 13,
                "public_key": "xxx"
            }
        ]
    }
}'
result.json
{
  "dnskey": {
    "data": [
      {
        "algorithm": 13,
        "flags": 256,
        "protocol": 3,
        "public_key": "xxx"
      }
    ],
    "ttl": 1200
  },
  "name": "cloudflare"
}

NS レコード設定

Cloudflare Nameservers xxx.ns.cloudflare.com を NS 1 の NS レコードに設定します。

image.png
image.png

Value Domain

DS レコード

Cloudflare と NS1 から取得できる DS レコード内容を Value Domain に設定します。

  • Cloudflare DS レコード
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dnssec" \                                                          
--header "X-Auth-Email: $EMAIL" \
--header "X-Auth-Key: $APIKEY"
  • NS1 DS レコード

ポータルから確認できる情報を以下のようにつなげて、DS レコード内容とします。
key_tag algorithm digest_type digest

image.png

  • Value Domain 設定

image.png

ネームサーバー

以下の6つのネームサーバーを登録します。

image.png

動作確認

ZSK がクロスインポートされている

% dig $ZONE_NAME dnskey @xxx.ns.cloudflare.com +noall +answer | grep 256
example.com.		3600	IN	DNSKEY	256 3 13 oJMRExxx==
example.com.		3600	IN	DNSKEY	256 3 13 pxEUuxxx==
% dig $ZONE_NAME dnskey @dns1.p09.nsone.net +noall +answer | grep 256
example.com.		3600	IN	DNSKEY	256 3 13 pxEUuxxx==
example.com.		3600	IN	DNSKEY	256 3 13 oJMRExxx==

DS レコードが複数設定されている

% dig $ZONE_NAME ds +noall +answer
example.com.		900	IN	DS	2371 13 2 DC134xxx
example.com.		900	IN	DS	48553 13 2 5AAD0xxx

複数の権威 DNS からの応答が検証できる

DNSSEC Analyzer を使って、以下のように Cloudflare と NS1 の両方で検証できていれば、Multi-signer DNSSEC です。

image.png

Visualize DNSSECDNSViz | A DNS visualization tool を使うと、DS レコードが複数存在する上で、どちらかが使われて、信頼のチェーンとなることが可視化できます。

image.png

以下の dig コマンドでも trace を確認できます。

dig A www.$ZONE_NAME +dnssec +trace

まとめ

比較的新しい RFC でまとめられている Multi-signer DNSSEC ですが、正しい手順を踏めば、DNSSEC を無効にすることなくドメイン移行する際の構成としては、難しくないと思います。

権威 DNS サービスを提供する事業者が、移行元・移行先の双方で DNSSEC 対応している必要がありますが、Cloudflare ではこうした構成に対応できることもわかりました。

その他参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?