-
-
Save stargieg/1b11d3df9cc6f9cb934037e6c474d618 to your computer and use it in GitHub Desktop.
# Define User Variables | |
:global ddnspass "TOKEN" | |
:global ddnshost "HOSTNAME.dynv6.net" | |
#:global ddnspool "pool0" | |
#:global ddnsinterface "bridge" | |
#:global ddnsinterface "6to4-henet" | |
#:global ddnsinterface "pppoe-out1" | |
#:global ddnsinterface "ether1" | |
# Define Global Variables | |
:global ddnsip | |
:global ddnslastip | |
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" } | |
# Define Local Variables | |
:local int | |
# Loop thru interfaces and look for ones containing | |
# default gateways without routing-marks | |
:if ([ :typeof $ddnsinterface ] != "str" ) do={ | |
:foreach int in=[ /ipv6 address find global ] do={ | |
:local testip [ /ipv6 address get $int address ] | |
:if ($testip in "fe80::/10" || $testip in "fc00::/7") do={ | |
} else={ | |
:global ddnsip $testip | |
} | |
} | |
} else={ | |
:if ([ :typeof $ddnspool ] != "str" ) do={ | |
# Grab the current Global IP address on that interface. | |
:foreach int in=[ /ipv6 address find interface=$ddnsinterface global ] do={ | |
:local testip [ /ipv6 address get $int address ] | |
:if ($testip in "fe80::/10" || $testip in "fc00::/7") do={ | |
} else={ | |
:global ddnsip $testip | |
} | |
} | |
} else={ | |
# Grab the current Global IP address on that interface from spec ip pool. | |
:global ddnsip [ /ipv6 address get [ /ipv6 address find interface=$ddnsinterface from-pool=$ddnspool ] address ] | |
} | |
} | |
# Did we get an IP address to compare? | |
:if ([ :typeof $ddnsip ] = nil ) do={ | |
:log info ("DynDNS: No ip address present on please check.") | |
} else={ | |
:log info ("DynDNS: check IPv6 UPDATE " . $ddnsip) | |
:if ($ddnsip != $ddnslastip) do={ | |
:log info "DynDNS: Sending IPv6 UPDATE!" | |
:local str "api/update\?hostname=$ddnshost&ipv6=$ddnsip&token=$ddnspass" | |
/tool fetch address="dynv6.com" host="dynv6.com" src-path="$str" mode=https dst-path=("/dynv6.".$ddnshost) | |
:delay 1 | |
:local str [/file find name="dynv6.$ddnshost"]; | |
/file remove $str | |
:global ddnslastip $ddnsip | |
} | |
} | |
# legacy IPv4 | |
# Define Global Variables | |
:global ddnsip4 | |
:global ddnslastip4 | |
:global ddnsinterface4 | |
:if ([ :typeof $ddnslastip4 ] = nil ) do={ :global ddnslastip4 "0" } | |
# Loop thru interfaces and look for ones containing | |
# default gateways without routing-marks | |
:local intfinder "" | |
:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={ | |
:set $intfinder [:tostr [/ip route get $int gateway-status]] | |
:set $intfinder [:pick $intfinder ([:find $intfinder "via"]+5) [:len $intfinder]] | |
:set $ddnsinterface4 $intfinder | |
} | |
# Grab the current IP address on that interface. | |
:set ddnsip4 [ /ip address get [/ip address find interface=$ddnsinterface4 ] address ] | |
:set ddnsip4 [:pick $ddnsip4 0 [:find $ddnsip4 "/"] ] | |
# Did we get an IP address to compare? | |
:if ([ :typeof $ddnsip4 ] = nil ) do={ | |
:log info ("DynDNS: No ip address present on " . $ddnsinterface4 . ", please check.") | |
} else={ | |
:log info ("DynDNS: check IPv4 UPDATE " . $ddnsip4) | |
:if ($ddnsip4 != $ddnslastip4) do={ | |
:log info "DynDNS: Sending IPv4 UPDATE!" | |
:local str "api/update\?hostname=$ddnshost&ipv4=$ddnsip4&token=$ddnspass" | |
/tool fetch address="dynv6.com" host="dynv6.com" src-path="$str" mode=https dst-path=("/dynv6.".$ddnshost) | |
:delay 1 | |
:local str [/file find name="DynDNS.$ddnshost"]; | |
/file remove $str | |
:global ddnslastip4 $ddnsip4 | |
} | |
} |
Привет, извините, если текст неверен: я использую Google для перевода.
Вывод моего журнала на Mikrotik:
08:25:35 script,info DynDNS: check IPv6 UPDATE 2804:339c:7bf::2:4f2c/64
08:25:35 script,info DynDNS: check IPv4 UPDATE 100.125.31.158
08:25:35 script,info DynDNS: check IPv4 UPDATE 100.125.31.158
08:25:38 firewall,info !LAN: input: in:ether1 out:(unknown 0)
Скрипт правильно определяет IP: 2804: 339c: 7bf :: 2: 4f2c / 64
Но когда я обновляю dynv6.com, появляется следующий вывод:
Current status
IPv4 Address 168.194.189.158
IPv6 Prefix 2804:339c:7bf::
Last update 1 minute ago
Мой IPv6-адрес обрезается после символа "::"
Вы когда-нибудь видели что-то подобное?
С этого момента спасибо!
Hi, sorry if the text is incorrect: I'm using Google to translate.
My LOG output on Mikrotik:
08:25:35 script,info DynDNS: check IPv6 UPDATE 2804:339c:7bf::2:4f2c/64
08:25:35 script,info DynDNS: check IPv4 UPDATE 100.125.31.158
08:25:35 script,info DynDNS: check IPv4 UPDATE 100.125.31.158
08:25:38 firewall,info !LAN: input: in:ether1 out:(unknown 0)
The script detects the IP correctly with: 2804:339c:7bf::2:4f2c/64
But when I update dynv6.com the following output appears:
Current status
IPv4 Address 168.194.189.158
IPv6 Prefix 2804:339c:7bf::
Last update 1 minute ago
My IPv6 address is being truncated after the "::"
Have you ever seen something similar?
Thanks from now on!
Hi, when I use this script witch pppoe-out1 interface, doesn't work. I get "-out1 reachable" in variable ddnsinterface4.