# dnscli
DNS 命令行工具,支持域名解析记录的增删改查。 现已适配以下DNS服务商
- [阿里云](https://www.aliyun.com/)
- [腾讯云](https://cloud.tencent.com/)
- ...
## 安装
```bash
pip install dnscli
```
## 命令说明
- alidns: 阿里云 DNS 命令行工具
- dnspod: 腾讯云 DNS 命令行工具
## 使用说明
以 alidns 为例,其他命令使用方式类似
1. 配置 API 信息
```bash
alidns configure --secret-id xxxxx --secret-key xxxxx
```
2. 查看域名列表
```bash
alidns list-domain
+------+---------------+--------------+--------+
| 序号 | 域名 | 创建时间 | 记录数 |
+------+---------------+--------------+--------+
| 1 | test1.com | 1592393820.0 | 9 |
| 2 | test2.com | 1592393160.0 | 6 |
| 3 | test.cn | 1448347860.0 | 14 |
+------+---------------+--------------+--------+
```
3. 查看域名解析记录
```bash
alidns list test.cn
+------+--------+----------+-------------------------------------+---------+-----+--------------------+--------------+--------------+
| 序号 | 子域名 | 记录类型 | 记录值 | 线路 | TTL | 记录 ID | 创建时间 | 更新时间 |
+------+--------+----------+-------------------------------------+---------+-----+--------------------+--------------+--------------+
| 1 | tt | AAAA | ::12 | default | 600 | 913272411669522432 | 1724317196.0 | 1724317196.0 |
| 2 | wfga | CNAME | www.baidu.com | default | 600 | 913225766055557120 | 1724294954.0 | 1724311099.0 |
+------+--------+----------+-------------------------------------+---------+-----+--------------------+--------------+--------------+
```
4. 添加域名解析记录
```bash
alidns create test.cn -n abc -v 1.2.3.4
+------+--------+----------+---------+---------+-----+----------+
| 序号 | 子域名 | 记录类型 | 记录值 | 线路 | TTL | 执行状态 |
+------+--------+----------+---------+---------+-----+----------+
| 1 | abc | A | 1.2.3.4 | default | 600 | 创建成功 |
+------+--------+----------+---------+---------+-----+----------+
```
5. 更新域名解析记录
```bash
alidns update test.cn -n abc -v 1.2.3.4 -nn foo -nv 22.2.111.1
+------+--------+----------+------------+---------+-----+--------------------+----------+
| 序号 | 子域名 | 记录类型 | 记录值 | 线路 | TTL | 记录ID | 执行状态 |
+------+--------+----------+------------+---------+-----+--------------------+----------+
| 1 | foo | A | 22.2.111.1 | default | 600 | 913431792258240512 | 修改成功 |
+------+--------+----------+------------+---------+-----+--------------------+----------+
```
6. 删除域名解析记录
```bash
alidns delete test.cn -n foo
+------+--------+----------+------------+---------+-----+----------+
| 序号 | 子域名 | 记录类型 | 记录值 | 线路 | TTL | 执行状态 |
+------+--------+----------+------------+---------+-----+----------+
| 1 | foo | A | 22.2.111.1 | default | 600 | 删除成功 |
+------+--------+----------+------------+---------+-----+----------+
```
> 注意:
> 1. 删除记录时, 子域名为必须参数
> 2. 删除记录时,只指定子域名,删除与子域名匹配的所有记录。
> 3. 如需删除特定的记录,请指定 记录ID (--record-id)
## 开发测试
1. 创建虚拟环境
2. 安装 `pip install -e .`
Raw data
{
"_id": null,
"home_page": null,
"name": "dnscli",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "alidns, aliyun, dns, dnscli, dnspod",
"author": null,
"author_email": "liwanggui <liwanggui@163.com>",
"download_url": "https://files.pythonhosted.org/packages/0a/9c/d2dd55c5e3c23599a891a7955287d3b77533ef22df8ccd531ee65ff382bf/dnscli-0.0.3.tar.gz",
"platform": null,
"description": "# dnscli\n\nDNS \u547d\u4ee4\u884c\u5de5\u5177\uff0c\u652f\u6301\u57df\u540d\u89e3\u6790\u8bb0\u5f55\u7684\u589e\u5220\u6539\u67e5\u3002 \u73b0\u5df2\u9002\u914d\u4ee5\u4e0bDNS\u670d\u52a1\u5546\n\n- [\u963f\u91cc\u4e91](https://www.aliyun.com/)\n- [\u817e\u8baf\u4e91](https://cloud.tencent.com/)\n- ...\n\n## \u5b89\u88c5\n\n```bash\npip install dnscli\n```\n\n## \u547d\u4ee4\u8bf4\u660e\n\n- alidns: \u963f\u91cc\u4e91 DNS \u547d\u4ee4\u884c\u5de5\u5177\n- dnspod: \u817e\u8baf\u4e91 DNS \u547d\u4ee4\u884c\u5de5\u5177\n\n## \u4f7f\u7528\u8bf4\u660e\n\n\u4ee5 alidns \u4e3a\u4f8b\uff0c\u5176\u4ed6\u547d\u4ee4\u4f7f\u7528\u65b9\u5f0f\u7c7b\u4f3c\n\n1. \u914d\u7f6e API \u4fe1\u606f\n ```bash\n alidns configure --secret-id xxxxx --secret-key xxxxx\n ```\n2. \u67e5\u770b\u57df\u540d\u5217\u8868\n ```bash\n alidns list-domain\n +------+---------------+--------------+--------+\n | \u5e8f\u53f7 | \u57df\u540d | \u521b\u5efa\u65f6\u95f4 | \u8bb0\u5f55\u6570 |\n +------+---------------+--------------+--------+\n | 1 | test1.com | 1592393820.0 | 9 |\n | 2 | test2.com | 1592393160.0 | 6 |\n | 3 | test.cn | 1448347860.0 | 14 |\n +------+---------------+--------------+--------+\n ```\n3. \u67e5\u770b\u57df\u540d\u89e3\u6790\u8bb0\u5f55\n ```bash\n alidns list test.cn\n +------+--------+----------+-------------------------------------+---------+-----+--------------------+--------------+--------------+\n | \u5e8f\u53f7 | \u5b50\u57df\u540d | \u8bb0\u5f55\u7c7b\u578b | \u8bb0\u5f55\u503c | \u7ebf\u8def | TTL | \u8bb0\u5f55 ID | \u521b\u5efa\u65f6\u95f4 | \u66f4\u65b0\u65f6\u95f4 |\n +------+--------+----------+-------------------------------------+---------+-----+--------------------+--------------+--------------+\n | 1 | tt | AAAA | ::12 | default | 600 | 913272411669522432 | 1724317196.0 | 1724317196.0 |\n | 2 | wfga | CNAME | www.baidu.com | default | 600 | 913225766055557120 | 1724294954.0 | 1724311099.0 |\n +------+--------+----------+-------------------------------------+---------+-----+--------------------+--------------+--------------+\n ```\n4. \u6dfb\u52a0\u57df\u540d\u89e3\u6790\u8bb0\u5f55\n ```bash\n alidns create test.cn -n abc -v 1.2.3.4\n +------+--------+----------+---------+---------+-----+----------+\n | \u5e8f\u53f7 | \u5b50\u57df\u540d | \u8bb0\u5f55\u7c7b\u578b | \u8bb0\u5f55\u503c | \u7ebf\u8def | TTL | \u6267\u884c\u72b6\u6001 |\n +------+--------+----------+---------+---------+-----+----------+\n | 1 | abc | A | 1.2.3.4 | default | 600 | \u521b\u5efa\u6210\u529f |\n +------+--------+----------+---------+---------+-----+----------+\n ```\n5. \u66f4\u65b0\u57df\u540d\u89e3\u6790\u8bb0\u5f55\n ```bash\n alidns update test.cn -n abc -v 1.2.3.4 -nn foo -nv 22.2.111.1\n +------+--------+----------+------------+---------+-----+--------------------+----------+\n | \u5e8f\u53f7 | \u5b50\u57df\u540d | \u8bb0\u5f55\u7c7b\u578b | \u8bb0\u5f55\u503c | \u7ebf\u8def | TTL | \u8bb0\u5f55ID | \u6267\u884c\u72b6\u6001 |\n +------+--------+----------+------------+---------+-----+--------------------+----------+\n | 1 | foo | A | 22.2.111.1 | default | 600 | 913431792258240512 | \u4fee\u6539\u6210\u529f |\n +------+--------+----------+------------+---------+-----+--------------------+----------+\n ```\n6. \u5220\u9664\u57df\u540d\u89e3\u6790\u8bb0\u5f55\n ```bash\n alidns delete test.cn -n foo\n +------+--------+----------+------------+---------+-----+----------+\n | \u5e8f\u53f7 | \u5b50\u57df\u540d | \u8bb0\u5f55\u7c7b\u578b | \u8bb0\u5f55\u503c | \u7ebf\u8def | TTL | \u6267\u884c\u72b6\u6001 |\n +------+--------+----------+------------+---------+-----+----------+\n | 1 | foo | A | 22.2.111.1 | default | 600 | \u5220\u9664\u6210\u529f |\n +------+--------+----------+------------+---------+-----+----------+\n ```\n > \u6ce8\u610f\uff1a\n > 1. \u5220\u9664\u8bb0\u5f55\u65f6, \u5b50\u57df\u540d\u4e3a\u5fc5\u987b\u53c2\u6570\n > 2. \u5220\u9664\u8bb0\u5f55\u65f6\uff0c\u53ea\u6307\u5b9a\u5b50\u57df\u540d\uff0c\u5220\u9664\u4e0e\u5b50\u57df\u540d\u5339\u914d\u7684\u6240\u6709\u8bb0\u5f55\u3002\n > 3. \u5982\u9700\u5220\u9664\u7279\u5b9a\u7684\u8bb0\u5f55\uff0c\u8bf7\u6307\u5b9a \u8bb0\u5f55ID (--record-id)\n\n## \u5f00\u53d1\u6d4b\u8bd5\n\n1. \u521b\u5efa\u865a\u62df\u73af\u5883\n2. \u5b89\u88c5 `pip install -e .`\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "\u57df\u540d\u89e3\u6790\u8bb0\u5f55\u7ba1\u7406\u5de5\u5177",
"version": "0.0.3",
"project_urls": {
"Changelog": "https://github.com/liwanggui/dnscli/release",
"Documentation": "https://github.com/liwanggui/dnscli",
"Homepage": "https://github.com/liwanggui/dnscli",
"Issues": "https://github.com/liwanggui/dnscli/issues",
"Repository": "https://github.com/liwanggui/dnscli"
},
"split_keywords": [
"alidns",
" aliyun",
" dns",
" dnscli",
" dnspod"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f7fb25996a73dc25c742c82b23ba8257ab7b69243d7ad0ca02c2d15965ebe0b0",
"md5": "c78952212b2a4e93ec24747b924e82c0",
"sha256": "81d8dfe8fa4bc01467162d5e195202e5b62daeb905219d0df665e1c279e445cc"
},
"downloads": -1,
"filename": "dnscli-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c78952212b2a4e93ec24747b924e82c0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 15367,
"upload_time": "2024-12-19T06:28:36",
"upload_time_iso_8601": "2024-12-19T06:28:36.143988Z",
"url": "https://files.pythonhosted.org/packages/f7/fb/25996a73dc25c742c82b23ba8257ab7b69243d7ad0ca02c2d15965ebe0b0/dnscli-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0a9cd2dd55c5e3c23599a891a7955287d3b77533ef22df8ccd531ee65ff382bf",
"md5": "70d4fa7101ab0385eedd93f9a1e778d2",
"sha256": "b64bb4e9004090aceda28ad1edc56b79743b0882264ccbbcad9ea45f6f06f107"
},
"downloads": -1,
"filename": "dnscli-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "70d4fa7101ab0385eedd93f9a1e778d2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 13412,
"upload_time": "2024-12-19T06:28:37",
"upload_time_iso_8601": "2024-12-19T06:28:37.581324Z",
"url": "https://files.pythonhosted.org/packages/0a/9c/d2dd55c5e3c23599a891a7955287d3b77533ef22df8ccd531ee65ff382bf/dnscli-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-19 06:28:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "liwanggui",
"github_project": "dnscli",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "dnscli"
}