局域網的routeros中設置Oray

  routeros可以運行Oray,但是在Oray的官方腳本中,routeros是默認作爲上網路由器的。
  (Oray官方文檔:http://service.oray.com/question/869.html

{
local ipaddr
local server "http://ddns.oray.com"
local domain "域名"
local par "/ph/update\?&hostname=$domain&myip=$ipaddr"
local users "用戶名"
local paswd "密碼"
:set ipaddr [/ip address get [/ip address find interface=pppoe-out1] address]
:set ipaddr [:pick $ipaddr 0 ([len $ipaddr] -3)]
/tool fetch url=($server . $par) mode=http user=$users password=$paswd
}

  從第8行代碼可以看出,該腳本是將pppoe-out1接口的IP當作公網IP,也就是說routeros必須是上網路由器,該腳本才能生效。

  但是如果routeros是在局域網裏面(例如routeros作爲內網服務器),外面還有一層路由器,那這個腳本就必須做修改,前提條件是routeros也能上網。

{
local ipaddr;
/tool fetch url="http://myip.dnsomatic.com/" mode=http dst-path=mypublicip.txt
local ip [file get mypublicip.txt contents ]
put $ip
:set ipaddr "$ip";
local server "http://ddns.oray.com";
local domain "域名";
local par "/ph/update\?&hostname=$domain&myip=$ipaddr";
local users "用戶名";
local paswd "密碼";
/tool fetch url=($server . $par) mode=http user=$users password=$paswd; 
}

  前面的5行代碼就是讓routeros上網獲取當前的公網IP,並保存在mypublicip.txt中,然後登陸Oray,註冊IP。
  (參考:https://forum.mikrotik.com/viewtopic.php?t=73287

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章