z-dns/README.md
wangzhengzhen 7d16e5a54c ddns
2024-07-01 09:39:16 +08:00

112 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# DNS域名解析工具
## 说明
该项目通过云服务商提供的API实现对账号下的域名进行添加查询更新删除操作。
目前仅接入阿里云DNS可以通过实现 `DnsProvider` 类,扩展其他云服务商。
### 配置
在云服务商后台配置生成授权信息,把 key 和 secret 配置到系统环境变量。
也可以在启动前设置临时变量
- windows
```
set ALIYUN_ACCESS_KEY_ID=阿里云ACCESS_KEY_ID
set ALIYUN_ACCESS_KEY_SECRET=阿里云ACCESS_KEY_SECRET
```
- linux
```
export ALIYUN_ACCESS_KEY_ID=阿里云 ACCESS_KEY_ID
export ALIYUN_ACCESS_KEY_SECRET=阿里云 ACCESS_KEY_SECRET
```
## 运行
编译完成后会生成可运行的jar包和原生应用
jar包运行(需安装java环境)
```
java -jar 生成的jar包 [参数1] [值1] [参数2] [值2] 操作
```
使用原生应用运行不需要单独安装java环境
```java
编译后的可执行文件 [参数1] [值1] [参数2] [值2] 操作
```
参数说明
| 参数 | 备注 |
| --------------- |---------------------------|
| provider | 服务提供商aliyun |
| domain | 域名baidu.com |
| rr | 记录和域拼接在一起为完整域名www |
| type | 解析类型A/AAAA/TXT/CNAME 等 |
| value | 记录值如果是A类型则对应IP地址以此类推 |
操作说明:
| 操作 | 备注 |
|--------|------|
| add | 添加域名 |
| view | 查看域名 |
| update | 更新域名 |
| delete | 域除域名 |
## 示例
- 设置临时环境变量
```
set ALIYUN_ACCESS_KEY_ID=阿里云ACCESS_KEY_ID
set ALIYUN_ACCESS_KEY_SECRET=阿里云ACCESS_KEY_SECRET
set ALIYU_REGION_ID=区域id
```
> ALIYUN_REGION_ID 非密填,默认 cn-hangzhou
> 其他区域可参考https://api.aliyun.com/product/Alidns cn-shenzhen
- 新增域名
```
dns.exe -provider aliyun -domain engr-z.com -rr test -type A -value 8.8.8.8 add
```
![img.png](img/img_add.png)
> ipv4是A记录ipv6是AAAA记录
- 查看域名
```
dns.exe -provider aliyun -domain engr-z.com -rr test show
```
- 更新域名
```
dns.exe -provider aliyun -domain engr-z.com -rr test -type A -value 8.8.4.4 update
```
![img_1.png](img/img_update.png)
- 删除域名
```
dns.exe -provider aliyun -domain engr-z.com -rr test delete
```
![img_2.png](img/img_delete.png)