|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
我是参考这个帖子做的:
http://bbs.routerclub.com/thread-9371-1-1.html
原贴在我机子上有点问题,改成如下,可正常使用,欢迎大家交流!
adscrz@163.com
附录Scrip:
# Dynamic DNS Update Script v1.1
# ------------------------------
# This script will perform automatic dynamic dns updates on the Mikrotik
# router platform. (http://www.mikrotik.com/) Since Mikrotik does not
# support sending http requests we have created a smtp -> ddns proxy service
# which will take the http URL querystring used for a dynamic dns update and
# process it via email.
# ------------------------------
# Written by Sam Norris, ChangeIP.com
# 7/31/04 - Created script.
# 12/9/04 - Made some values dynamic (smtp server, dhcp interface)
# ------------------------------
#
# Instructions:
# There are a few variables down below that you need to configure for your
# specific setup. Please modify the variables in the 'ddnsInit' script to
# reflect your specific information, ie userid, password, hostname to update.
#
# Blow away any existing script code, if necessary.
/system scheduler remove ddnsJob
/system script remove ddnsCheck
/system script remove ddnsInit
/system script remove ddnsReset
/system script remove ddnsSendUpdate
# Setup global variables needed to keep track of changing IP address.
/system script add name="ddnsInit" source={
:log message="ddnsInit: Creating Dynamic DNS update system."
# ENTER YOUR CHANGEIP.COM USER ID HERE.
:global u
:set u "adscrz"
# ENTER YOUR CHANGEIP.COM PASSWORD HERE.
:global p
:set p "××××××××"
:global s
:set s "Mikrotik"
# ENTER THE TARGET HOSTNAME TO UPDATE, *1 is Set 1.
:global h
:set h "*1"
:global dhcpInterface
:log message=("Get interface" )
:set dhcpInterface "pppoe-out1"
:log message=("ddnsInit: Found dhcp interface " . $dhcpInterface )
# EMAIL PROXY ADDRESS - DO NOT CHANGE FOR PRODUCTION.
:global ddnsProxyEmail
:set ddnsProxyEmail "ddnsUpdate@ChangeIP.com"
# ENTER YOUR EMAIL ADDRESS FOR CONFIRMATIONS.
:global ddnsFromEmail
# :set ddnsFromEmail "youremail@domain.tld"
:set ddnsFromEmail "adscrz@163.com"
# SMTP DDNS PROXY SERVER - CHANGE ONLY IF NECESSARY (port 25 blocked?)
:global ddnsSmtpServer
:set ddnsSmtpServer [:resolve smtp.changeip.com]
:global a
:set a [ \
/ip address get \
[/ip address find interface=$dhcpInterface] \
address \
]
}
/system script add name="ddnsCheck" source={
#开机后运行几次
:if ([/system resource get uptime] < 120s ) do={
:log message=("Start time =" . [/system resource get uptime])
:log message=("Will run ddnsSendUpdate...")
/system script run ddnsSendUpdate
}
:if ([/system scheduler get ddnsJob run-count]<=1) do={
/system script run ddnsInit
}
:global temp
:global b
:set temp $a
:set b [ \
/ip address get \
[/ip address find interface=$dhcpInterface] \
address \
]
:log message=("IP address: " . $b )
:if ($temp != $b) do={
:log message="ddnsCheck: Found new IP address."
/system script run ddnsSendUpdate
:set a $b
}
}
/system script add name="ddnsSendUpdate" source={
:log message=("ddnsSendUpdate: Sending Dynamic DNS smtp update to " . $ddnsSmtpServer)
/tool e-mail send \
to=$ddnsProxyEmail \
from=$ddnsFromEmail \
server=$ddnsSmtpServer \
subject="New Dynamic IP" \
body=("u=" . $u . "&p=" . $p . "&hostname=" . $h . "&system=" . $s . "&myip=" . $b)
}
/system script add name="ddnsReset" source={
:log message="ddnsReset: Resetting global values."
/system scheduler set ddnsJob run-count=0
:unset u
:unset p
:unset s
:unset h
:unset dhcpInterface
:unset ddnsProxyEmail
:unset ddnsFromEmail
:unset ddnsSmtpServer
:unset a
:unset b
:unset temp
}
/system scheduler add name=ddnsJob interval=30s on-event=ddnsCheck
/system scheduler add name=ddnsupdate interval=60m on-event=ddnsSendUpdate |
|