Skip to content

Instantly share code, notes, and snippets.

@flandersen
Created March 8, 2024 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flandersen/40352705e15083cd18e0de71caced82a to your computer and use it in GitHub Desktop.
Save flandersen/40352705e15083cd18e0de71caced82a to your computer and use it in GitHub Desktop.
Update DynDNS IP address with RouterOS (MikroTik router)

Update DynDNS IP address with RouterOS (MikroTik router)

API documentation of noip.com: https://www.noip.com/integrate/request

Creating the required base64-auth-string with Python:

import base64
auth_str = 'your-user:your-password'
byte_str = auth_str.encode('ascii')
auth_b64 = base64.b64encode(byte_str)
print(auth_b64)

Example Output = NVpTWERNTm5JRmNnSzhKUWs0THo7

Test with curl:

First, replace placeholders <...>.

curl -H "Host: dynupdate.no-ip.com" -H "Authorization: Basic <your-base64-credentials>" -H "User-Agent: <Company> <Devide>/<Firmware> <Email Contact>" -d "hostname=<your-dyndns-address>" -X POST https://dynupdate.no-ip.com/nic/update

Implement in RouterOS

  1. Login to MikroTik router with Putty
  2. Convert your credentials for noip.com to base64-encoded-auth-string as shown above.
  3. Add script to RouterOS:
/system script
add name=dyndns-update comment="Update IP address" source={/tool fetch url="https://dynupdate.no-ip.com/nic/update" mode=https http-method=post http-data="hostname=<your-dyndns-address>" host="dynupdate.no-ip.com" http-header-field="User-Agent: <Company> <Devide>/<Firmware> <Email Contact>, Authorization: Basic <your-base64-credentials>"}

Info: Replace placeholders <...>.

  1. Test the script.
  2. Add scheduler to RouterOS:
/system scheduler
add disabled=no start-time=startup interval=5m name=dyndns-update on-event="/system script run dyndns-update"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment