zoukankan      html  css  js  c++  java
  • 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"
      }
    }
  • 相关阅读:
    InstallShield 2010集成.net Framework 4的安装包制作
    linux之稀疏文件
    linux之od命令
    Python多线程
    GCC编译器和GDB调试器常用选项
    Linux GDB Debug
    Linux Core Dump
    linux 通过 ulimit 改善系统性能
    linux的ulimit命令
    字符编码笔记:ASCII,Unicode和UTF-8
  • 原文地址:https://www.cnblogs.com/itfat/p/14749140.html
Copyright © 2011-2022 走看看