返回列表 發帖

自動更新no-ip ddns Script!!

本帖最後由 gfx86674 於 2015-2-16 17:30 編輯

小弟個人debug並優化的no-ip自動更新Script ,有興趣的朋友可試試
  1. #===========no-ip資訊=============
  2. :local noipuser "abc1234@gmail.com"
  3. :local noippass "123456"
  4. :local noiphost "abc1234.no-ip.org"
  5. #=================================
  6. :if ([/ip cloud get ddns-enabled]=no) do={/ip cloud set ddns-enabled=yes}
  7. /ip cloud force-update ;:delay 3
  8. :local noipnew [/ip cloud get public-address]

  9. :global noipold
  10. :if ([:typeof $noipold]="nothing") do={:set noipold [:resolve $noiphost]}

  11. :if ($noipnew!=$noipold) \
  12.     do={:local url "/nic/update?hostname=$noiphost&myip=$noipnew"
  13.         /tool fetch address=dynupdate.no-ip.com src-path=$url mode=http \
  14.                    user=$noipuser password=$noippass dst-path=("ddns-noip")
  15.         :delay 1

  16.         :local filestr [/file get "ddns-noip" contents]
  17.         /file remove [/file find name="ddns-noip"]

  18.         :if ([:find $filestr "good"]="0"||[:find $filestr "nochg"]="0") \
  19.             do={:log warning ("更新no-ip地址: ".$noipnew)
  20.                 :set noipold $noipnew} \

  21.             else={:log error "更新no-ip失敗!!"}}
複製代碼
成功更新log:

本帖最後由 gfx86674 於 2015-2-16 16:56 編輯

回復 2# yiucsw
注意更新v6.27後 ,cloud名稱有變,所以腳本也要跟著變!
更新前:
:if ([/ip cloud get enabled]=no) do={/ip cloud set enabled=yes}

更新後:
:if ([/ip cloud get ddns-enabled]=no) do={/ip cloud set ddns-enabled=yes}

TOP

本帖最後由 gfx86674 於 2015-2-28 02:05 編輯

回復 5# yiucsw
noip免費用戶每個月本來就至少得上官網做登錄 一次,每個月期限前官網也會寄mail通知.
忘了被暫停只能說是個人的疏失,這點腳本無法做任何幫助.

或者乖乖成為noip付費會員,hostname就不會被無端暫停了,就這樣!

另外小弟編輯了2.0版本 ,需要的人可自行運用.
  1. #===========no-ip資訊=============
  2. :local pppoename1 "pppoe-out1"

  3. :local noipuser "abc1234@gmail.com"
  4. :local noippass "123456"
  5. :local noiphost1 "abc1234.no-ip.org"
  6. #==========================
  7. :local publicip1 [/ip address get [find interface=$pppoename1] address]
  8. :set publicip1 [:pick $publicip1 0 [:find $publicip1 "/"]]
  9. :set publicip1 [:toip $publicip1]

  10. :local noipold1 [:resolve $noiphost1]

  11. :if ($publicip1!=$noipold1) \
  12.     do={:local url "/nic/update?hostname=$noiphost1&myip=$publicip1"
  13.         /tool fetch address=dynupdate.no-ip.com src-path=$url mode=http \
  14.                    user=$noipuser password=$noippass dst-path=("ddns-noip")
  15.         :delay 1

  16.         :local filestr [/file get "ddns-noip" contents]
  17.         /file remove [/file find name="ddns-noip"]

  18.         :if ([:find $filestr "good"]="0"||[:find $filestr "nochg"]="0") \
  19.             do={:log warning ("更新no-ip地址: ".$publicip1)} \

  20.             else={:log error "更新no-ip失敗!!"}}
複製代碼

TOP

本帖最後由 gfx86674 於 2015-3-6 01:05 編輯

第一個腳本是將Public-ip設到DDNS ,但只能更新一組.
第二個腳本是將PPPoE-IP設到DDNS ,修改後可以一次更新兩組DDNS,或者是更多.

若ISP是用DHCP-Client IP給用戶 ,其實這與PPPoE沒有什不同.
差別只在名稱一個為PPPoE-OUT1 ,另一個則是Client-name罷了.

TOP

返回列表