V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
clanned
V2EX  ›  分享创造

cloudxns 动态域名更新 shell 脚本

  •  
  •   clanned · 2015-12-06 19:32:58 +08:00 · 5089 次点击
    这是一个创建于 3065 天前的主题,其中的信息可能已经有所发展或是发生改变。

    源码地址
    https://github.com/xdtianyu/scripts/tree/master/ddns

    可用于 ddwrt 和 openwrt 路由,只需要 sh 运行(系统基本环境)

    下载 shell 脚本

    wget https://raw.githubusercontent.com/xdtianyu/scripts/master/ddns/cloudxns.sh
    wget https://raw.githubusercontent.com/xdtianyu/scripts/master/ddns/cloudxns.conf
    chmod +x cloudxns.sh
    

    配置文件

    API_KEY="YOUR_API_KEY"
    SECRET_KEY="YOUR_SECRET_KEY"
    DOMAIN="example.com"
    HOST="ddns"
    LAST_IP_FILE="/tmp/.LAST_IP"
    

    cron 定时任务

    */3 * * * * /root/ddns/cloudxns.sh /root/ddns/cloudxns.conf >> /root/ddns/cloudxns.log
    

    脚本会在更新成功后记录 ip ,只有当 ip 变化后才会再运行更新

    更详细的说明在我的博客 https://www.xdty.org/1907

    7 条回复    2016-09-04 17:27:07 +08:00
    lll9p
        1
    lll9p  
       2015-12-07 02:13:42 +08:00
    在 dnspod 上用 Python 写过一个类似的☺
    wm5d8b
        2
    wm5d8b  
       2015-12-07 08:51:04 +08:00 via Android
    自己用 Python 写的经常更新 IP 失败,看到这个才想起来应该在更新后校验一下😁
    clanned
        3
    clanned  
    OP
       2015-12-07 09:14:19 +08:00
    @lll9p 源码地址里也有 dnspod 的动态域名 shell 更新脚本哦,用了很久了,这几天 dnspod 对 8.8.8.8 解析出问题了所以我转到 cloudxns 了
    CloudXNS
        4
    CloudXNS  
       2015-12-30 17:27:49 +08:00
    赞!~
    感谢楼主分享。
    danili
        5
    danili  
       2016-03-28 20:19:26 +08:00
    谢谢楼主分享,请问如果我想同时给"@","www","ddns"更新 IP 的花 conf 文件应该如何修改呢?
    clanned
        6
    clanned  
    OP
       2016-03-29 00:19:46 +08:00   ❤️ 1
    @danili 更新 ddns.example.com, @ 和 www 在 dns 解析里通过 cname 指向到 ddns.example.com
    danili
        7
    danili  
       2016-09-04 17:27:07 +08:00
    用了挺久了,今天在路由器上刷了 SS 之后发现域名更新到国外服务器上去了....查了下原来用来查询 ip 的这个域名解析成国外的地址出错了。改成一个国内的更稳更快些。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5371 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 08:31 · PVG 16:31 · LAX 01:31 · JFK 04:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.