局域网的routeros中设置Oray

老子叫甜甜 提交于 2020-01-19 22:31:16

  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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!