Linux 纯 Shell 实现 DNSPod 动态域名

开发背景:

公司有台嵌入式拨号上网设备,内置 busybox 和完整 wget 命令(支持https协议),但没有 curl、python、ruby、php 等扩展工具可用。网上现有基于DNSPod实现的Linux脚本无法在该设备上运行,于是写了个Shell版动态域名客户端(ddnspod-shell),现在发布出来希望能给需要的朋友带来一些方便。

项目源码:

https://github.com/rehiy/dnspod-shell

DnsPod 官方文档

https://docs.dnspod.cn/api/update-dns-records/

功能介绍:

  • 优雅的函数封装,灵活的更新策略
  • 基于DNSPod最新用户API实现动态域名客户端
  • 支持基于系统计划任务实现更新,防止脚本意外终止
  • 可运行于多数类 unix 系统中,包括部分嵌入式小型系统
  • 依赖 ip/sed/wget 命令,wget 也可使用 curl 替代

常见问题:

record line invailid 将脚本保存为utf-8格式即可
record id invalid 检查账号权限、是否冲突等

文章作者: 若海; 原文链接: https://www.rehiy.com/post/62/; 转载需声明来自技术写真 - 若海

已有 95 条评论

  1. danis

    我也一样是报错 get record info failed。

  2. 19年12月31日更新后就无法使用了!!提示
    root@raspbian:/home/pi/ddns# ./ddnspod.sh
    Type: A
    OS: Linux
    Address: 115.221.12.117
    Updating Domain: .Timcc.xyz
    hostIP: 115.221.12.117
    Get Record Info Failed!

    1. 若海

      已更新

  3. wang

    我在gcp上的centos使用这个脚本提示host ip是10.170.0.33
    最后还有个Get Record Info Failed

  4. wang

    我在gcp上的centos使用这个脚本提示host ip是10.170.0.33
    最后还有个Get Record Info Failed

  5. 毛阿花

    大神 openwrt 18.06.04 路由器重启后 日志报“Get Record Info Failed!” 怎么解决 以前没有这种问题

    1. 信息太少无法判断

  6. 好学的小王

    ArDNSPod可以同时解析ipv4和ipv6么

  7. hiben

    Get Record Info Failed!
    请问怎么解决。

    1. 运行环境请贴下

  8. jack

    root@OpenWrt:/usr/lib/ddns# ./ddnspod.sh
    Linux
    ./ddnspod.sh: /usr/lib/ddns/dns.conf: line 1: arToken=***: not found
    ./ddnspod.sh: /usr/lib/ddns/dns.conf: line 2: ip: not found
    ./ddnspod.sh: /usr/lib/ddns/dns.conf: line 2: ip: not found
    Updating Domain: .blocks
    hostIP:
    wget: can't execute 'openssl': No such file or directory
    wget: error getting response: Connection reset by peer
    wget: can't execute 'openssl': No such file or directory
    wget: error getting response: Connection reset by peer
    wget: can't execute 'openssl': No such file or directory
    wget: error getting response: Connection reset by peer
    Get Record Info Failed!
    ./ddnspod.sh: /usr/lib/ddns/dns.conf: line 3: ip: not found
    ./ddnspod.sh: /usr/lib/ddns/dns.conf: line 3: ip: not found
    Updating Domain: *
    hostIP:
    wget: can't execute 'openssl': No such file or directory
    wget: error getting response: Connection reset by peer
    wget: can't execute 'openssl': No such file or directory
    wget: error getting response: Connection reset by peer
    wget: can't execute 'openssl': No such file or directory
    wget: error getting response: Connection reset by peer
    Get Record Info Failed!
    root@OpenWrt:/usr/lib/ddns# wget: can't execute 'openssl': No such file or direc
    tory

    1. jack

      在openwrt中安装openssl-util就解决了openssl的问题。

      1. 因为dnspod现在是通过https协议请求数据,所以必须使用openssl

        1. ddht

          大神,
          我的centos用openssl version -a,检查了是有openssl的,为什么还是不行。

          1. 主要看是否支持 curl 或者 wget with https

      2. jack

        root@OpenWrt:/# /usr/lib/ddns/ddnspod.sh
        Linux
        /usr/lib/ddns/ddnspod.sh: /usr/lib/ddns/dns.conf: line 1: #: not found
        /usr/lib/ddns/ddnspod.sh: /usr/lib/ddns/dns.conf: line 8: ip: not found
        /usr/lib/ddns/ddnspod.sh: /usr/lib/ddns/dns.conf: line 8: ip: not found
        Updating Domain: **
        hostIP:
        Get Record Info Failed!
        新问题
        貌似没有获取IP地址。

  9. 我用这个更新了ip,怎么设置ttl 目前ttl值是10 需要怎么修改

  10. 为什么我取得是本机IP,不是公网IP,请指教,谢谢

    1. Anakie

       

      arIpAddress() {

      }

      里面的内容全删掉 ,花括号里只留下面一句

       

      wget -qO - ifconfig.co

      1. ad

        获得外网IP了,但是Get Record Info Failed! 高手,还有办法吗

添加新评论