局域网的routeros中设置Oray

  routeros能够运行Oray,可是在Oray的官方脚本中,routeros是默认做为上网路由器的。
  (Oray官方文档:http://service.oray.com/question/869.htmlphp

{
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必须是上网路由器,该脚本才能生效。 html

  可是若是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=73287dom

相关文章
相关标签/搜索