routerOS3系列DDNS更新脚本

此脚本来自官方,完全自动判断。

只需要加入自己的免费域名供应商的注册账号和密码以及域名即可

下面内容为脚本,修改前三行变量即可

 

 
  1. :global ddnsuser "用户名" 
  2. :global ddnspass "密码" 
  3. :global ddnshost "域名" 
  4. :global ddnsip  
  5. :global ddnslastip  
  6. :if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }  
  7. :global ddnsinterface  
  8. :global ddnssystem ("mt-" . [/system package get system version] )  
  9. :local int 
  10. :foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={   
  11.   :if ([:typeof [/ip route get $int routing-mark ]] != str ) do={  
  12.      :global ddnsinterface [/ip route get $int interface]  
  13.   }   
  14. }  
  15. :global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]  
  16. :if ([ :typeof $ddnsip ] = nil ) do={  
  17.    :log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")  
  18. else={  
  19.   :if ($ddnsip != $ddnslastip) do={  
  20.     :log info "\BF\AA\CA\BC\B8\FC\D0\C2\D4\B6\B3\CC\D3\F2\C3\FB" 
  21.     :log info [ :put [/tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ] ]  
  22.     :global ddnslastip $ddnsip  
  23.   } else={   
  24.     :log info "ip\B5\D8\D6\B7\CE\DE\B1\E4\BB\AF,\D3\F2\C3\FB\B2\BB\D3\C3\B8\FC\D0\C2" 
  25.   }  
  26. }  
  27. #end 

 

你可能感兴趣的:(更新,职场,域名,休闲,ddns,routeros)