zoukankan      html  css  js  c++  java
  • ROS实现DNSPod的DDNS服务脚本

    在ROS上实现DDNS服务

     一、登陆ROS,system ---> scripts,新建一个脚本,脚本内容粘贴在Source。

     二、脚本

      登陆DNSPod,点击头像--->密钥管理,新建一个新密钥,修改下方脚本代码即可

    #PPPoE
    :local pppoe "pppoe-ddns"
    
    #DNSPOD token
    :local token "id,token"
    
    #域名
    :local domain "domain.com"
    
    #域名主机名
    :local subdomain "subdomain"
    
    
    #domain
    :local dname ($subdomain.".".$domain)
    
    #获取pppoe拨号ip
    :local ipaddr [/ip address get [/ip address find interface=$pppoe] address]
    :set ipaddr [:pick $ipaddr 0 ([len $ipaddr] -3)]
    
    #获取域名列表
    :local record [/tool fetch url="https://dnsapi.cn/Record.List" http-data="login_token=$token&format=json&domain=$domain&sub_domain=$subdomain&record_type=A" as-value output=user]
    
    #获取id和ip
    :set record ($record->"data")
    :set record [:pick $record [:find $record ""records":"] [:len $record]]
    :local recordid [:pick $record ([:find $record ""id":""]+6) [:find $record "","ttl"]]
    :local recordip [:pick $record ([:find $record ""value":""]+9) [:find $record "","en"]]
    
    #更新ip地址
    :if ($recordip!=$ipaddr) do={
    /tool fetch url="https://dnsapi.cn/Record.Ddns" http-data="login_token=$token&format=json&domain=$domain&sub_domain=$subdomain&record_id=$recordid&record_line_id=0&value=$ipaddr"
    :log info ("[".$dname."] ip update")
    } else={
    :log info ("[".$dname."] ip not update")
    }
  • 相关阅读:
    一个matlab小程序:挑出沪市A股年报与一季度报在同一天发布的股票
    AWK
    matlab搜索路径
    从新浪财经上下载交易明细数据并统计每天的买卖笔数(shell 命令行)
    AWK截取字符串
    tar GNU
    工作效率上的错觉(转载)
    matlab双精度浮点数编码及区间覆盖(原创)
    DNS服务器设置(Ubuntu10.04)
    sed
  • 原文地址:https://www.cnblogs.com/yellowzunzhi/p/13589474.html
Copyright © 2011-2022 走看看