Giter Site home page Giter Site logo

jwping / aliddns Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 11.0 4 KB

阿里云域名解析动态更新(DDNS)的Shell脚本,同时支持IPv4以及IPv6。Ali cloud domain name resolution dynamic update (DDNS) shell script, while supporting IPv4 and IPv6.

Shell 100.00%
aliyun aliyun-dns ddns shell bash ipv4 ipv6

aliddns's Introduction

AliDDNS

介绍

如果使用了阿里云(万网)的域名解析服务的话,那么就可以通过它提供的API,使用HTTP访问动态修改解析地址,以实现DDNS的功能。阿里云也提供了一些语言的SDK,但是并没有Shell版本的。

此shell是在h46incon的动态更新脚本基础上进行修改完善的,添加了同时对于IPv4和IPv6的支持。

注意:此脚本只实现了调用修改域名解析记录获取解析记录列表的API的功能,并没有完整实现整个SDK。但是因为脚本已经实现了API的签名机制,所以很容易实现其他API的调用。

参考:阿里云解析API文档

功能

  • 仅在当前IP地址和域名解析设置不同时,发起更新请求。(本机当前IP地址通过3322.org提供的API 进行查询,域名的解析设置通过dig,向公共DNS服务器直接进行查询。)
  • 查看账户下所有的域名信息。

使用方法

1. 安装依赖

首先需要一个shell(目前仅在 bash 上测试通过,其他shell未测试)。

然后安装 bind-digcurlopenssl-util。这些软件包在OpenWRT下可直接使用 opkg 命令安装。

2. 修改基础配置

修改脚本的ipv4ipv6函数,其中DomainRecordId不清楚的话暂时不用修改,如:

#Accesskey在开头Setting代码段中修改。
AccessKeyId="MyID"
AccessKeySec="MySecret"

此处的DNS解析服务器为万网,如无特殊需求可以不做修改。

DNSServer="dns9.hichina.com"

修改Domain*在尾部ipv4或ipv6的函数调用中修改,DomainRR为需要监控的二级域名,DomainName为需要监控的域名。

DomainRecordId="00000"
DomainRR="www"
DomainName="example.com"
DomainType="A"

3. 查看DomainRecordId

如果不清楚DomainRecordId的话,修改ipv4ipv6函数,在里面调用describe_record,如:

	ipv6()
	{
		describe_record
		#update_record
	}

然后执行这个脚本。如果没问题的话,就能获取到域名的所有解析记录的列表了:

{"PageNumber":1,"TotalCount":1,"PageSize":1,"RequestId":"0000","DomainRecords":
  {"Record":[{"RR":"www","Status":"ENABLE","Value":"8.8.8.8",
  "RecordId":"21332133","Type":"A","DomainName":"example.com",
  "Locked":false,"Line":"default","TTL":"600"},]}
  }HttpCode:200

上面的结果中,RecordId为21332133。得到结果后再修改DomainRecordId为正确的值。

4. 执行脚本

基础配置完成后,改回原入口函数:

	ipv6()
	{
		#describe_record
		update_record
	}

执行脚本即可,脚本会在本机IP地址和当前域名解析设置不同的时候调用API更新设置。

aliddns's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aliddns's Issues

IPv6的地址

获取IPv6的地址时,因为没有全局变量,导致无法保持参数。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.