局域网的ROS中设置花生壳

在花生壳的官方脚本中,是将ROS默认作为上网的路由器。

{
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作为VPN服务器),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

猜你喜欢

转载自blog.51cto.com/trance/2119791