局域網的ROS中設置花生殼

在花生殼的官方腳本中,是將ROS默認作爲上網的路由器。
(花生殼官方文檔:http://service.oray.com/question/869.html
{
local ipaddr
local server "http://ddns.oray.com"
local domain "domain.gicp.net"
local par "/ph/update\?&hostname=$domain&myip=$ipaddr"
local users "username"
local paswd "abc123"
: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
}
從:set ipaddr [/ip address get [/ip address find interface=pppoe-out1] address]這行代碼可以看出,ROS直接將pppoe-out1接口的IP當作公網IP。
   

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

{
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 "domain.gicp.net";
local par "/ph/update\?&hostname=$domain&myip=$ipaddr";
local users "username";
local paswd "abc123";
/tool fetch url=($server . $par) mode=http user=$users password=$paswd;
}
前面的幾行斜體代碼就是讓ROS上網獲取公網IP,並保存在mypublicip.txt中,然後登陸Oray,註冊IP。
(參考:https://forum.mikrotik.com/viewtopic.php?t=73287

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