|
|
- # Dynadot DDNS Update Script for RouterOS 7.19
- :local ddnsInterface "pppoe-out1"
- :local dynadotHostname "your-domain.com"
- :local dynadotAPIKey "your-api-key-from-dynadot"
- # Get current IPv4 address from specific interface
- :local currentIPv4 [/ip address get [/ip address find interface=$ddnsInterface] address]
- :set currentIPv4 [:pick $currentIPv4 0 [:find $currentIPv4 "/"]]
- # Get current IPv6 address (from global scope on bridge)
- :local ipv6Addr [/ipv6 address get [/ipv6 address find interface=bridge1 advertise=yes] address]
- :local currentIPv6 ""
- :if ([ :typeof $ipv6Addr ] != "nil") do={
- :set currentIPv6 [:pick $ipv6Addr 0 [:find $ipv6Addr "/"]]
- }
- # Resolve current DNS record
- :local dnsIPv4 [:resolve $dynadotHostname type=A server=8.8.8.8]
- :local dnsIPv6 [:resolve $dynadotHostname type=AAAA server=2001:4860:4860::8888]
- # Update only if IP changed
- :if (($currentIPv4 != $dnsIPv4) || ($currentIPv6 != $dnsIPv6)) do={
- :log info "Dynadot: IP change detected, updating DNS records"
-
- # Update IPv4 via Dynadot API
- :if ($currentIPv4 != $dnsIPv4) do={
- /tool fetch url=("https://api.dynadot.com/api3.xml?key=" . $dynadotAPIKey . "&command=set_dns2&domain=" . $dynadotHostname . "&a_record1=" . $currentIPv4) mode=https keep-result=no
- :log info "Dynadot: IPv4 updated to $currentIPv4"
- }
-
- # Update IPv6 via Dynadot API
- :if (($currentIPv6 != "") && ($currentIPv6 != $dnsIPv6)) do={
- /tool fetch url=("https://api.dynadot.com/api3.xml?key=" . $dynadotAPIKey . "&command=set_dns2&domain=" . $dynadotHostname . "&aaaa_record1=" . $currentIPv6) mode=https keep-result=no
- :log info "Dynadot: IPv6 updated to $currentIPv6"
- }
- } else={
- :log info "Dynadot: No IP change detected"
- }
复制代码 不知道deepseek上生成的代码要怎么改?
|
|