Skip to content

Instantly share code, notes, and snippets.

@ergolyam
Last active November 17, 2024 00:35
Show Gist options
  • Select an option

  • Save ergolyam/939ed26ca786af787c0b9b89be2aea64 to your computer and use it in GitHub Desktop.

Select an option

Save ergolyam/939ed26ca786af787c0b9b89be2aea64 to your computer and use it in GitHub Desktop.
freedomain DynDNS for mikrotik
# MikroTik Script: freedomain.rsc
# Purpose: Update DNS records dynamically
:local apiKey "api_key"
:local domain "example.com,example.org"
:local fileName "last_pppoe_ip.txt"
:local lastIP
:local currentIP
:if ([/file find name=$fileName] = "") do={
/file print file=$fileName
:log info "File $fileName created."
}
:if ([/file find name=$fileName] != "") do={
:set lastIP [/file get [/file find name=$fileName] contents]
}
# command to get ip from pppoe interface
:set currentIP [/ip address get [find interface="pppoe-out1"] address]
:if ($currentIP != $lastIP) do={
:local url "https://api.dnsexit.com/dns/ud/?apikey=$apiKey"
/tool fetch url=$url http-method=post http-data="host=$domain" mode=https dst-path=/dev/null keep-result=no
:file set [/file find name=$fileName] contents=$currentIP
:log info "DNS record for $domain updated to $currentIP."
} else={
:log info "No changes in IP address. Update not required."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment