• ros使用godaddy的ddns服务来更新*IP


    先记录下,回头测试下

    原文:

    https://gist.github.com/nansenat16/bbedb728a486b4a7fb76ae031995a317

    #GoDaddy DDNS Update Script
    #Test with RouterOS 6.45.2 (Minimum version RouterOS 6.44)
    #Date:2019/08/02
    #The read,write,policy,test that all of these policies need to be set in script for the global variable 
    
    #ref1 https://www.instructables.com/id/Quick-and-Dirty-Dynamic-DNS-Using-GoDaddy/
    #ref2 http://www.minitw.com/post/2018/05/09/routeros-ddns-namecheap
    
    #Easy Test
    # /tool fetch url="https://api.godaddy.com/v1/domains/[domain]/records/A/[hostname]" http-method=put http-data="[{"data": "10.10.10.10"}]" http-header-field="content-type: application/json,Authorization: sso-key [API_KEY]:[API_SECRET]"
    
    #Create Schedule running
    # /system scheduler add name=update-ddns interval=1m on-event=godaddy-ddns
    
    #kye token format is [API_KEY]:[API_SECRET]
    :local ddnkey "Authorization: sso-key [API_KEY]:[API_SECRET]"
    :local ddnsdomain "[domain]"
    :local ddnshostname "[hostname]"
    :local ddnsinterface "pppoe-adsl"
    
    #Use global variable to check if need update
    :global ddnslastipADSL1
    :global ddnsipADSL1 [/ip address get [/ip address find actual-interface=$ddnsinterface] address ]
    :if ([:typeof [:global ddnslastipADSL1]] = nil ) do={ :global ddnslastipADSL1 0.0.0.0/0 } else={ :set ddnslastipADSL1 $ddnslastipADSL1 }
    
    :if ([:typeof [:global ddnsipADSL1]] = nil ) do={
      :log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
    } else={
      :if ($ddnsipADSL1 != $ddnslastipADSL1) do={
        :local ipFormat [:pick $ddnsipADSL1 0 [:find $ddnsipADSL1 "/"]];
        :log info "DDNS-Update use $ddnsinterface IP : $ipFormat"
        :local ddnsurl "https://api.godaddy.com/v1/domains/$ddnsdomain/records/A/$ddnshostname" 
        :local ddnsipjson "[{"data": "$ipFormat"}]"
        :local result [/tool fetch url=$ddnsurl http-method=put http-data=$ddnsipjson http-header-field="content-type: application/json,$ddnkey" as-value output=user]
        :if ($result->"status" = "finished") do={
            :log info ($ddnshostname . "." . $ddnsdomain . " Update IP " . $ipFormat . " Success")
            :global ddnslastipADSL1 $ddnsipADSL1
        } else={
            :log info ("DDNS Update Error".$result->status)
        }
      } else={
        :log info "DDNS: IP No Change"
      }
    }
  • 相关阅读:
    TypeScript & JSDoc All In One
    k8s & Docker All In One
    How to custom your own Node.js Docker Image All In One
    rollup & TypeScript & tslib All In One
    Linux file system All In One
    how to use npm delete one history version package All In One
    How to use Web Components in React or Vue All In One
    看了这篇使用 dist 发布 npm 包的文章,我整个人都栓Q 了
    yarn 1.x & yarn 2.x All In One
    python中删除字符串中的指定字符
  • 原文地址:https://www.cnblogs.com/itfat/p/14749140.html
Copyright © 2020-2023  润新知