按照本教程将现有 DNS zone 迁移到 Cloudflare,而无需禁用 DNSSEC。
这是一项高级流程,并假设你对 DNS 概念、API 操作 以及基本设置步骤有一定熟悉度。本教程未详细说明的假定知识,可通过各步骤中的链接内容查阅。
你要从其迁移的提供商必须允许你在 zone apex 上添加 DNSKEY 记录,并在对 DNS 查询的响应中使用这些记录。
-
要通过 API 添加 zone,请参阅 Create Zone 端点。
-
要通过 API 导入 zone 文件,请参阅 Import DNS Records 端点。
-
在 DNS Settings(DNS 设置) ↗ 页面,选择 Enable DNSSEC(启用 DNSSEC)。或使用以下 API 请求。
Required API token permissions
At least one of the following token permissions is required:DNS Write
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dnssec" \
--request PATCH \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"status": "active"
}'- 在 DNS Settings(DNS 设置) ↗ 页面,启用 Multi-signer DNSSEC(多方签名 DNSSEC)。或使用以下 API 请求。
Required API token permissions
At least one of the following token permissions is required:DNS Write
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dnssec" \
--request PATCH \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"dnssec_multi_signer": true
}'- 通过在 zone 上创建 DNSKEY 记录,将先前提供商的 ZSK ↗ 添加到 Cloudflare。
你可以在仪表板上完成此操作,或通过 Create DNS Record 端点,如下例所示。
Required API token permissions
At least one of the following token permissions is required:DNS Write
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"type": "DNSKEY",
"name": "<ZONE_NAME>",
"data": {
"flags": 256,
"protocol": 3,
"algorithm": 13,
"public_key": "<PUBLIC_KEY>"
},
"ttl": 3600
}'- 使用 API 或从某个已分配的 Cloudflare 名称服务器发起查询,获取 Cloudflare 的 ZSK。
API 示例:
curl https://api.cloudflare.com/client/v4/zones/{zone_id}/dnssec/zsk \
--header "X-Auth-Email: <EMAIL>" \
--header "X-Auth-Key: <API_KEY>"命令行查询示例:
dig <ZONE_NAME> dnskey @<CLOUDFLARE_NAMESERVER> +noall +answer | grep 256- 将上一步获取的 Cloudflare ZSK 添加到你先前的提供商。
- 将 Cloudflare DS 记录添加到你的注册商。你可以在 DNS Settings(DNS 设置) ↗ 页面的 DS Record(DS 记录) 下查看 Cloudflare DS 记录。
- 将 Cloudflare 分配的名称服务器添加到你的注册商。你可以在 DNS Records(DNS 记录) ↗ 页面查看 Cloudflare 名称服务器。
此时,你的 zone 处于多方签名 DNSSEC 设置。