创新|开发|定制
专注于软路由|网络技术领域

ROS-DDNS for Oray(花生壳) for emial

脚本的主要功能是,检测pppoe-out1的IP是否有变动,没变动不执行,变动就执行,执行后会把ROS设备的基本信息发送到邮箱。(路由型号、系统版本、当前IP、DDNS更新回传信息ROS自带DDNS名称等)

方法如下:

1、在/System Script下添加如下脚本内容

{
  local ipaddr
  local server "http://ddns.oray.com"
  local domain "xinok.cn,www.xinok.cn"
  local users "user"
  local paswd "password"
  local logname "ddns.log"
  local pppoename "pppoe-out1"
  local smtps "smtp.qq.com"
  local ports "25"
  local Mailings "user@qq.com"
  local pass "password"
  local recipient "user@qq.com"
  local Collection "user@qq.com"
  local Contents "Is your latest public IP address:"
  local Themes "ros-ddns-info"
  local content "Following your RouterOS with the latest info"
  local smtp [:resolve $smtps]
  global lastip
  global rosversion ("Your Router Version is MikroTik v" . [/system resource get version] )
  global rosboard ("Your Router Board is " . [/system resource get board] )
  global dnsname ("Your Router dnsname is " . [/ip cloud get dns] )
  :set ipaddr [/ip address get [/ip address find interface=$pppoename] address]
  :set ipaddr [:pick $ipaddr 0 ([len $ipaddr] -3)]
  :if ($ipaddr != $lastip) do={
    :set lastip $ipaddr
    local par "/ph/update?&hostname=$domain&myip=$ipaddr"
    /tool fetch url=($server . $par) mode=http user=$users password=$paswd keep-result=yes 
	dst-path=$logname
	:local logcontent [ /file get $logname contents];
    /file remove [/file find name=$logname]
	:local ddnsinfo "DDNS update return value is $logcontent"
	/tool e-mail set address=$smtp port=$ports from=$Collection user=$Collection password=$pass
    :log warning "DDNS: get wan ip from $pppoename:$ipaddr"
	:log warning "DDNS: has request from ddns:$logcontent"
	/tool e-mail send to=$recipient from=$Collection subject=$Themes body=("$contentn$rosboardn$rosversionn$Contents$lastipn$ddnsinfon$dnsname")
	:log warning "DDNS: Sends current info to Email:$Collection"
  } else={
  }
}

脚本名称命名为OrayDDNS
2、在/System Scheduler下添加一个脚本定时,名称为OrayDDNS,内容为OrayDDNS,执行时间
为3分钟(时间可自定义)
注意:单线单拨可用

赞(0) 打赏
转载请注明出处:Ros资源网 » ROS-DDNS for Oray(花生壳) for emial

评论 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏