返回列表 發帖
回復 66# mrandrewchan


    see what you mean, and I added it accordingly.
But I am wondering what is the differece of
1. adding it in the  first coming up dialog
2. press the static button, adding it

TOP

It is working now. Tks a lot

TOP

回復 70# mrandrewchan


    Tks a lot for helping and reminding me.

TOP

So, it is working perfectly on RB750 v5.24:
System>Script>add script "dyndns"

############
# Set needed variables
############
# Your DynDNS account user-name, password & host-name.
:local username "yourusername"
:local password "yourpassword"
:local hostname "yourhostname"

# Which interface are we checking if DHCP has changed? [interfaces | name column in winbox]
:local DHCPInterface "yourinterface"
############
# This is the name of the file where the last recorded IP will be stored, as well as the file name of the DynDNS response.
# Make sure if another script is using files, that these names don't conflict.
# You probably also want to be sure they aren't the same as any other files on the disk - because you'll be clobbering those files.
# Finally, while I'm not aware of any "reserved" file names on the disk, it would be wise to avoid something that might conflict.
# Prefixing them with something to associate them with this script would probably be a good thing.
# You can point these files at your SD-disk too, if you have an SD card installed and ready on your RB. Just prefix the path appropriately:
# something like this [:local vLastIPFileName "micro-sd/dyndns-lastip.txt"] (don't put a leading slash)
# A user reported a bug if you use the RB flash and prefix the path with a [/]
# So for RB based flash, it's probably safest to use just something like [:local vLastIPFileName "dyndns-lastip.txt"] and not [:local vLastIPFileName "/dyndns-lastip.txt"]
# You ***MUST*** use a .txt extension. Just an oddity of ROS. Move along now.
# Code ForDD
:local vLastIPFileName "dyndns-lastip.txt"
:local vDynDNSResponseFile "dyndns-resp.txt"
# /dyndns.txt

############
# END Set needed variables
############

:local vlen;
:local vRawIP;
:local vJustIP;
:local currentIP
:local previousIP
:local vlocalurl
:local vIPChanged false
:local dyndnsresult
:local result

# Check for file existance, if not create it
# We need to do this before we try to read or write to files...
:local check [/file find name=$vLastIPFileName]
:if ( $check = "" ) do= {
   /file print file=$vLastIPFileName
   :delay 2
   /file set [/file find name=$vLastIPFileName] contents=""
}

# Get the last saved IP from the file.
:set previousIP [/file get $vLastIPFileName contents]
#:put $previousIP


# print some debug info
:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: password = $password")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")
:log info ("UpdateDynDNS: DHCPInterface = $DHCPInterface")


# This code gets the current IP from the interface.
# The interface we're checking should be set above.
# get the raw IP from the interface, which includes a mask.
:set vRawIP [:tostr [/ip address get [find interface=$DHCPInterface] address]]

#Strip the netmask off the vRawIP address.
:for i from=( [:len $vRawIP] - 1) to=0 do={
        :if ( [:pick $vRawIP $i] = "/") do={
                :set vJustIP [:pick $vRawIP 0 $i]
        }
}
:set currentIP $vJustIP

# Determine if dyndns update is needed
# more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html
# Update if the currentIP isn't equal to previousIP.
:if (($currentIP != $previousIP)) do={
        :log info "CurrentIP: $currentIP - PreviousIP: $previousIP"
        :set vlocalurl ("http://" . "$username" . ":" . "$password" . "@" . "members.dyndns.org" . "/nic/update?hostname=" . "$hostname" . "&myip=" . "$currentIP")   
        /tool fetch mode=http url=$vlocalurl dst-path=$vDynDNSResponseFile
        :set result [/file get $vDynDNSResponseFile contents]
        :set vIPChanged true
} else={
   :log info ("UpdateDynDNS: No dyndns update needed")
}

# Get the result status code and pull it out for use.
# IF IPChanged = true
#        Get result code
#                Check DynDNS result
#                if good or nochg, then
#                        :set previousIP $currentIP
#                        /file set [/file find name=$vLastIPFileName] contents="$currentIP"
#                        also post the result to the log file       
#                else badauth or !donator or notfqdn, nohost, abuse, dnserr, 911
#                        post to log file
#                        Don't update previousIP or vLastIPFileName file
:if ($vIPChanged=true) do={
        :set result [/file get $vDynDNSResponseFile contents]
        :local endLoc [:find $result " " -1]
        :set dyndnsresult [:pick $result -1 ($endLoc)]
        :put $dyndnsresult
                :if (($dyndnsresult = "good") || ($dyndnsresult = "nochg") ) do={
                        :set previousIP $currentIP
                        :log info ("UpdateDynDNS: Dyndns update needed")
                        :log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
                        /file set [/file find name=$vLastIPFileName] contents="$currentIP"
                        } \
                else={
                        :log info ("UpdateDynDNS: Dyndns update needed")
                        :log info ("DynDNS Update FAILED")
                        :log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
                }
}

New Terminal> /system scheduler add name=dyndns interval=00:01 on-event="/system script run dyndns\r\n"

TOP

离我嘅目标又行近一步啦!

TOP

回復 74# 角色


    唔系,我网上抄嘅,无留意一个!

TOP

有冇CHING知道以下:
我已经注册咗个dyndns.org "DynDNS Pro" service, 加咗一个域名,但係佢上面点解话MAX 31个域名?如果我再加多个,会唔会扣我嘅服务期?
例如,一个就十二个月,两个就剩下6个,如此类推?

如果唔会,咁可唔可以multi-sites,例如:

host_A.dyndns.org:係香港
host_B.dyndns.org:係大陆公司
host_C.dyndns.org:係大陆宿舍

如果可以,咁咪超平!!!

TOP

我试过reboot RouterBoard,之后个public IP转左,都可以喎。

TOP

回復 79# 角色


    咁請問邊個Scripts 好d ?佢個wiki裡面專門俾5.x 嘅?

TOP

冇呀!我就係用佢做router,  佢唔係NAT後面啦

TOP

回復 83# 角色


    暂时没有啦!

TOP

本帖最後由 bky16 於 2013-4-5 14:31 編輯

终于setup咗个linux mail server,都装咗squirrelmail,佢default係行port 80,但我发觉做完port forwarding后:

/ip firewall nat add chain=dstnat dst-port=80 action=dst-nat protocol=tcp to-address=10.30.20.212 to-port=80

客户端所有BROWSWER打开网页都俾指到个linux server处,除咗改squirrelmail嘅port之外,routeros可唔可以点改法?
唔係应该有source address(例如 192.168.0.1)去destination address公网(例如:8.8.8.8),就唔会被直接指去个linux server度?

mail server係NAT后面,因为冇设定DMZ
我做咗PORT FORWARDING 去mail server 嘅 port(如:110,25,465....),80因为squirrelmail要行。

TOP

本帖最後由 bky16 於 2013-4-5 14:52 編輯

回復 89# 雯雯
吓!
所以,係唔係应该搵个port做DM Zone会易得 ?

TOP

本帖最後由 bky16 於 2013-4-5 18:19 編輯
回復  bky16

你個Mail server對外開, 你有沒有在你個domain的DNS server set返正解和反解? ...
雯雯 發表於 2013-4-5 15:37



    查咗一下!好似做唔到REVERSE LOOKUP,我用俾钱嘅dyndns.org服务,但系上面好似冇将点set reverse lookup,所有我谂係唔係应该OK呢?
但依个同出唔出街应该冇关系。

依家改咗些少,唔知啱唔啱
0   chain=srcnat action=masquerade
1   chain=srcnat action=masquerade src-address=10.30.30.0/24
2   chain=dstnat action=dst-nat to-addresses=10.30.20.212 to-ports=110
     protocol=tcp in-interface=pppoe-out1 dst-port=110
3   chain=dstnat action=dst-nat to-addresses=10.30.20.212 to-ports=995
     protocol=tcp in-interface=pppoe-out1 dst-port=995
4   chain=dstnat action=dst-nat to-addresses=10.30.20.212 to-ports=25
     protocol=tcp in-interface=pppoe-out1 dst-port=25 port=""
5   chain=dstnat action=dst-nat to-addresses=10.30.20.212 to-ports=465
     protocol=tcp in-interface=pppoe-out1 dst-port=465
6   chain=dstnat action=dst-nat to-addresses=10.30.20.212 to-ports=143
     protocol=tcp in-interface=pppoe-out1 dst-port=143
7   chain=dstnat action=dst-nat to-addresses=10.30.20.212 to-ports=993
     protocol=tcp in-interface=pppoe-out1 dst-port=993

其实係改咗个in interface 为pppoe,出街冇问题不过重係有问题。

TOP

回復  bky16

NAT rule for web server:



Mail server:
Qnewbie 發表於 2013-4-5 16:26



    唔该!我睇睇先

TOP

返回列表