Skip to content

Instantly share code, notes, and snippets.

@sabueso
Created January 8, 2017 14:06
Show Gist options
  • Save sabueso/8ad0b9ad02e3ce8b60ae39305eefba60 to your computer and use it in GitHub Desktop.
Save sabueso/8ad0b9ad02e3ce8b60ae39305eefba60 to your computer and use it in GitHub Desktop.
Mikrotik bind dynamic zone update
:global ipaddressfull [/ip address get [find interface="vlan2"] address]
:global ipaddress [:pick $ipaddressfull 0 [:find $ipaddressfull "/"]]
:global actualhostnameip 0.0.0.0
:do {
:put [:global actualhostnameip [:resolve host.toupdate.com]];
} on-error={ :log info "update_bind_test: Error retrieving host ip";}
:if ($ipaddress != $actualhostnameip) do={
:log info "update_bind_test: Different data, local ip $ipaddress => remote hostname $actualhostnameip, updating...";
/tool dns-update dns-server=ip_server name="toupdate" address="$ipaddress" key-name="name_of_the_key" key="yourhashkey" zone="toupdate.com" ttl=300;
} else={
:log info "update_bind_test: nothing to do, all updated...";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment