局域网的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

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