aliyun-dns-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCategory: 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.
- 通过查询和管理阿里云DNS记录。
aliyun-cli - 快速为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/aliyunbash
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/aliyunConfigure Credentials
配置凭证
bash
~/.local/bin/aliyun configure set \
--profile default \
--access-key-id <AK> \
--access-key-secret <SK> \
--region cn-hangzhouConfigure 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.comAdd 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.comExample (Hangzhou):
1629965279769872.cn-hangzhou.fc.aliyuncs.com自定义域名需要指向FC公网CNAME地址:
<account_id>.<region_id>.fc.aliyuncs.com示例(杭州区域):
1629965279769872.cn-hangzhou.fc.aliyuncs.comCommon Issues
常见问题
- If apex CNAME is not supported, use subdomain like or ALIAS/ANAME records.
www - Create FC custom domain only after DNS propagation, otherwise may occur.
DomainNameNotResolved
- 如果根域名不支持CNAME,请使用这类子域名,或者使用ALIAS/ANAME记录。
www - 请等待DNS解析生效后再创建FC自定义域名,否则可能会出现错误。
DomainNameNotResolved
References
参考资料
-
aliyun-cli installation
-
Alidns API(AddDomainRecord / DescribeSubDomainRecords)
-
FC custom domain configuration and CNAME guidance
-
Official source list:
references/sources.md
-
aliyun-cli安装
-
Alidns API(AddDomainRecord / DescribeSubDomainRecords)
-
FC自定义域名配置与CNAME指引
-
官方资源列表:
references/sources.md
Validation
验证
bash
mkdir -p output/aliyun-dns-cli
echo "validation_placeholder" > output/aliyun-dns-cli/validate.txtPass criteria: command exits 0 and is generated.
output/aliyun-dns-cli/validate.txtbash
mkdir -p output/aliyun-dns-cli
echo "validation_placeholder" > output/aliyun-dns-cli/validate.txt通过标准:命令退出码为0,且成功生成文件。
output/aliyun-dns-cli/validate.txtOutput 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, optionalALICLOUD_ACCESS_KEY_SECRET.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
工作流程
- Confirm user intent, region, identifiers, and whether the operation is read-only or mutating.
- Run one minimal read-only query first to verify connectivity and permissions.
- Execute the target operation with explicit parameters and bounded scope.
- Verify results and save output/evidence files.
- 确认用户意图、区域、标识符,以及操作是只读还是变更类操作。
- 先运行一次最简的只读查询,验证连通性和权限。
- 使用明确参数和有限范围执行目标操作。
- 验证结果并保存输出/凭证文件。