aliyun-dns-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Category: tool
分类:工具

Alibaba Cloud DNS (Alidns) CLI

阿里云DNS(Alidns)CLI

Goals

目标

  • Query and manage Alibaba Cloud DNS records via
    aliyun-cli
    .
  • Quickly configure CNAME for Function Compute custom domains.
  • 通过
    aliyun-cli
    查询和管理阿里云DNS记录。
  • 快速为Function Compute自定义域名配置CNAME。

When to Use

适用场景

  • When you need to add/update DNS records in Alibaba Cloud DNS.
  • When you need CNAME setup for FC custom domains.
  • 你需要在阿里云DNS中添加/更新DNS记录时。
  • 你需要为FC自定义域名配置CNAME时。

Install aliyun-cli (without sudo)

安装aliyun-cli(无需sudo权限)

bash
curl -fsSL https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz -o /tmp/aliyun-cli.tgz
mkdir -p ~/.local/bin
 tar -xzf /tmp/aliyun-cli.tgz -C /tmp
mv /tmp/aliyun ~/.local/bin/aliyun
chmod +x ~/.local/bin/aliyun
bash
curl -fsSL https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz -o /tmp/aliyun-cli.tgz
mkdir -p ~/.local/bin
 tar -xzf /tmp/aliyun-cli.tgz -C /tmp
mv /tmp/aliyun ~/.local/bin/aliyun
chmod +x ~/.local/bin/aliyun

Configure Credentials

配置凭证

bash
~/.local/bin/aliyun configure set \
  --profile default \
  --access-key-id <AK> \
  --access-key-secret <SK> \
  --region cn-hangzhou
Configure region as default; if best region is unclear, ask the user.
bash
~/.local/bin/aliyun configure set \
  --profile default \
  --access-key-id <AK> \
  --access-key-secret <SK> \
  --region cn-hangzhou
将区域配置为默认值;如果不清楚最优区域,请询问用户。

Query DNS Records

查询DNS记录

Query subdomain records:
bash
~/.local/bin/aliyun alidns DescribeSubDomainRecords \
  --SubDomain news.example.com
查询子域名记录:
bash
~/.local/bin/aliyun alidns DescribeSubDomainRecords \
  --SubDomain news.example.com

Add CNAME Record

添加CNAME记录

bash
~/.local/bin/aliyun alidns AddDomainRecord \
  --DomainName example.com \
  --RR news \
  --Type CNAME \
  --Value <TARGET>
bash
~/.local/bin/aliyun alidns AddDomainRecord \
  --DomainName example.com \
  --RR news \
  --Type CNAME \
  --Value <TARGET>

FC Custom Domain CNAME Target

FC自定义域名CNAME目标地址

Custom domain should point to FC public CNAME:
<account_id>.<region_id>.fc.aliyuncs.com
Example (Hangzhou):
1629965279769872.cn-hangzhou.fc.aliyuncs.com
自定义域名需要指向FC公网CNAME地址:
<account_id>.<region_id>.fc.aliyuncs.com
示例(杭州区域):
1629965279769872.cn-hangzhou.fc.aliyuncs.com

Common Issues

常见问题

  • If apex CNAME is not supported, use subdomain like
    www
    or ALIAS/ANAME records.
  • Create FC custom domain only after DNS propagation, otherwise
    DomainNameNotResolved
    may occur.
  • 如果根域名不支持CNAME,请使用
    www
    这类子域名,或者使用ALIAS/ANAME记录。
  • 请等待DNS解析生效后再创建FC自定义域名,否则可能会出现
    DomainNameNotResolved
    错误。

References

参考资料

Validation

验证

bash
mkdir -p output/aliyun-dns-cli
echo "validation_placeholder" > output/aliyun-dns-cli/validate.txt
Pass criteria: command exits 0 and
output/aliyun-dns-cli/validate.txt
is generated.
bash
mkdir -p output/aliyun-dns-cli
echo "validation_placeholder" > output/aliyun-dns-cli/validate.txt
通过标准:命令退出码为0,且成功生成
output/aliyun-dns-cli/validate.txt
文件。

Output And Evidence

输出与凭证留存

  • Save artifacts, command outputs, and API response summaries under
    output/aliyun-dns-cli/
    .
  • Include key parameters (region/resource id/time range) in evidence files for reproducibility.
  • 将产物、命令输出和API响应摘要保存在
    output/aliyun-dns-cli/
    目录下。
  • 在凭证文件中包含关键参数(区域/资源ID/时间范围),方便后续复现操作。

Prerequisites

前置条件

  • Configure least-privilege Alibaba Cloud credentials before execution.
  • Prefer environment variables:
    ALICLOUD_ACCESS_KEY_ID
    ,
    ALICLOUD_ACCESS_KEY_SECRET
    , optional
    ALICLOUD_REGION_ID
    .
  • If region is unclear, ask the user before running mutating operations.
  • 执行前配置最小权限的阿里云凭证。
  • 优先使用环境变量:
    ALICLOUD_ACCESS_KEY_ID
    ALICLOUD_ACCESS_KEY_SECRET
    ,可选
    ALICLOUD_REGION_ID
  • 如果不清楚区域设置,在执行变更操作前先询问用户。

Workflow

工作流程

  1. Confirm user intent, region, identifiers, and whether the operation is read-only or mutating.
  2. Run one minimal read-only query first to verify connectivity and permissions.
  3. Execute the target operation with explicit parameters and bounded scope.
  4. Verify results and save output/evidence files.
  1. 确认用户意图、区域、标识符,以及操作是只读还是变更类操作。
  2. 先运行一次最简的只读查询,验证连通性和权限。
  3. 使用明确参数和有限范围执行目标操作。
  4. 验证结果并保存输出/凭证文件。