forked from alexanderfefelov/mikrotik-routeros-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdyndns-client.rsc
25 lines (23 loc) · 1.25 KB
/
dyndns-client.rsc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#-------------------------------------------------------------------------------
# MikroTik RouterOS DynDNS Update Client
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Settings
#-------------------------------------------------------------------------------
:local DYNDNSUSER "user"
:local DYNDNSPASSWORD "password"
:local DYNDNSHOSTNAME "host.dyndns.info"
:local EXTERNALINTERFACE "ether1"
#-------------------------------------------------------------------------------
# Update
#-------------------------------------------------------------------------------
:local currentIp [/ip address get [/ip address find interface=$EXTERNALINTERFACE] address]
:set currentIp [:pick $currentIp 0 [: find $currentIp "/"]]
:local oldIp [:resolve $DYNDNSHOSTNAME]
:if ($currentIp != $oldIp) do={
:local addr "members.dyndns.org"
:local srcPath "/nic/update?hostname=$DYNDNSHOSTNAME&myip=$currentIp&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
:local dstPath "dyndns.txt"
/tool fetch address=$addr src-path=$srcPath mode=https user=$DYNDNSUSER password=$DYNDNSPASSWORD dst-path=$dstPath keep-result=no
:log info "DynDNS updated: $DYNDNSHOSTNAME $oldIp -> $currentIp"
}