利用阿里云的DDNS

  • 第一回知道自己购买了阿里云的域名之后就能免费使用阿里云的DDNS,我把家里的IP加入到阿里云的云解析之后,果然通过端口222成功的访问了我的安保监控系统,你们就别试了,我的服务器在第三层之下,还加密了port-222
  • 再按照https://blog.csdn.net/pzhier/article/details/111570930此文的方法拿到aliyun的AccessKey,这样为之后自动化跑IP记录值更新最准备
  • 自动化跑IP记录值更新,需要pip安装1.aliyun ddns的核心sdk,2.安装alidns,3.或者用pip3安装aliyun-python-sdk-core-v3,https://github.com/mgsky1/DDNS/blob/master/README_ZH_CN.md这里我选择利用pip3安装aliyun-python-sdk-core-v3 代码都已经过时,自己写了一个,这里不多说了
  • 在脚本config.json里面更新自己的key
 064933       : ************ ************** ************** **************
 064933  note : PID '14825' started at 2023-09-02 06:49
 064933       : ddns version  : 2.7.8-3
 064933       : uci configuration:
ddns.aliddns.domain='home.Mytest.com.cn'
ddns.aliddns.enabled='1'
ddns.aliddns.ip_source='web'
ddns.aliddns.lookup_host='home.Mytest.com.cn'
ddns.aliddns.password='***PW***'
ddns.aliddns.service_name='aliyun.com'
ddns.aliddns.username='L*********************H4'
ddns.aliddns=service
 064933       : verbose mode  : 0 - run normal, NO console output
 064933       : check interval: 600 seconds
 064933       : force interval: 259200 seconds
 064933       : retry interval: 60 seconds
 064933       : retry counter : 0 times
 064933       : No old process
 064934       : last update: never
 064934       : Detect registered/public IP
 064934       : #> /usr/bin/host -t A home.Mytest.com.cn  >/var/run/ddns/aliddns.dat 2>/var/run/ddns/aliddns.err
 064934       : Registered IP '8.8.8.8' detected
 064934  info : Starting main loop at 2023-09-02 06:49
 064934       : Detect local IP on 'web'
 064934       : #> /usr/bin/wget-ssl -nv -t 1 -O /var/run/ddns/aliddns.dat -o /var/run/ddns/aliddns.err --no-proxy 'http://checkip.dyndns.com'
 064934       : Local IP '8.8.8.8' detected on web at 'http://checkip.dyndns.com'
 064934       : Forced Update - L: '8.8.8.8' == R: '8.8.8.8'
 064934       : parsing script '/usr/lib/ddns/update_aliyun_com.sh'
 064935       : #> wget --no-hsts -nv -t 1 -O /var/run/ddns/aliddns.dat -o /var/run/ddns/aliddns.err --no-proxy 'http://alidns.aliyuncs.com/?Action=DescribeSubDomainRecords&SubDomain=home.Mytest.com.cn&Format=JSON&TTL=600&Version=2015-01-09&AccessKeyId=LTAI5tJy4oSUqzcygn51R7H4&SignatureMethod=HMAC-SHA1&Timestamp=2023-09-01T22%3A49%3A35Z&SignatureVersion=1.0&SignatureNonce=5f9ef514-7fa6-46dd-8c36-871087aca736&Signature=0q7BTXVB8vuSRW8tt08aIv06HsM%3D'
 064935       : 获取到解析记录: {"TotalCount":1,"PageSize":20,"RequestId":"DF34E130-A3E5-5833-BAC4-D1DD26A3EFB4","DomainRecords":{"Record":[{"Status":"ENABLE","Line":"default","RR":"home","Locked":false,"Type":"A","DomainName":"Mytest.com.cn","Value":"8.8.8.8","RecordId":"848078242135446528","TTL":600,"Weight":1}]},"PageNumber":1}
 064936       : 获得解析记录ID: 848078242135446528, 类型: A
 064936  info : Forced update successful - IP: '8.8.8.8' send
 064936       : Waiting 600 seconds (Check Interval)
 065936       : Detect registered/public IP
 065936       : #> /usr/bin/host -t A home.Mytest.com.cn  >/var/run/ddns/aliddns.dat 2>/var/run/ddns/aliddns.err
 065936       : Registered IP '8.8.8.8' detected
 065936  info : Rerun IP check at 2023-09-02 06:59
 065936       : Detect local IP on 'web'
 065936       : #> wget -nv -t 1 -O /var/run/ddns/aliddns.dat -o /var/run/ddns/aliddns.err --no-proxy 'http://checkip.dyndns.com'
 065937       : Local IP '8.8.8.8' detected on web at 'http://checkip.dyndns.com'
 065937       : Waiting 600 seconds (Check Interval)