ROS的DDNS指令碼

來源:互聯網
上載者:User

標籤:

ROS使用ADSL上網時,每次撥號IP都會改變,導致外網訪問ROS伺服器失敗,目前最常見的解決方案是使用DDNS這種動態網域名稱工具,在撥號後(IP發生變化後)通知DDNS伺服器更新IP,最終使用DDNS服務商提供的靜態網域名稱即可永久訪問這台伺服器。ROS官方僅支援changeip,但通過其它方法也可以實現支援花生殼,測試通過的指令碼如下:

一、國外changeip的指令碼,修改自changeip官方網站:

 1 # Define User Variables 2 :global ddnsuser "user" 3 :global ddnspass "password" 4 :global ddnshost "xxxx.onmypc.org" 5 :global ddnsinterface "changkuan" 6  7 # Define Global Variables 8 :global ddnsip 9 :global ddnslastip10 11 :if ([ :typeof $ddnslastip ] = nothing ) do={ :global ddnslastip "0" }12 13 # Grab the current IP address on that interface.14 :global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]15 :log info $ddnsip16 # Did we get an IP address to compare?17 :if ([ :typeof $ddnsip ] = nil ) do={18    :log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")19 } else={20 21   :if ($ddnsip != $ddnslastip) do={22 23     :log info "DDNS: Sending UPDATE!"24     :log info [ :put [/tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ] ]25     :global ddnslastip $ddnsip26 27   } else={ 28     :log info "DDNS: No update required."29   }30 31 }32 33 # End of script

二、國內花生殼的指令碼,官方提供的指令碼每次都會更新,根據上述changip指令碼修改之,實現IP變化後才更新:

 1 local server "http://ddns.oray.com" 2 local domain "xxxx.oicp.net" 3 local users "user" 4 local paswd "password" 5 local adslinterface "changkuan" 6 local ipaddr 7 :global lastipaddr 8  9 set ipaddr [/ip address get [/ip address find interface=$adslinterface] address]10 :if ([ :typeof $ipaddr ] = nil ) do={11    :log info ("ORAY: No ip address present on " . $adslinterface . ", please check.")12 } else={13    set ipaddr [:pick $ipaddr 0 ([len $ipaddr] -3)]   14    :log info $ipaddr15    :if ($ipaddr != $lastipaddr) do={16     local par "/ph/update?&hostname=$domain&myip=$ipaddr"17     :log info "ORAY: Sending UPDATE!"18     :log info [:put [ /tool fetch url=($server . $par) mode=http user=$users password=$paswd ] ]19     :global lastipaddr $ipaddr20 21   } else={ 22     :log info "ORAY: No update required."23   }24 }

 

ROS的DDNS指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.