Mikrotik Duckdns.org Update (New Script)

Share on facebook
Share on twitter
Share on linkedin
Share on telegram
Share on whatsapp
Share on email

Table of Contents


Entah kenapa script untuk update Dynamic IP Public via Duckdns yang lama seperti dalam postinganku yang terdahulu “Duck DNS Update Script For Mikrotik” mendadak macet. Alhasil ketika akan me-remote router jarak jauh jadi gagal.

Supaya dapat kembali update Dynamic IP Public, silahkan gunakan script berikut ini, simple dan ada penambahan record IP Public ke address list, untuk rule redirect IP.

# DuckDNS Full Domain (FQDN)
:local duckdnsFullDomain "subdomain.duckdns.org"

# DuckDNS Sub Domain
:local duckdnsSubDomain "subdomain"

# DuckDNS Token
:local duckdnsToken "12345678-aaaa-bbbb-cccc-1234567890aa"

# The interface name with the assigned dynamic IP address (usually the WAN interface).
:local wanInterface "Ether0-Gateway"

# Log destination
:local logDestination "/disk1/logs/"

#-------------------------------------------------------------------------------------------------------------------------

:log warning message="START: DuckDNS.org DDNS Update"

:if ([/interface get $wanInterface value-name=running] = true) do={

#   Get the previous IP via DNS resolution.
    :local previousIP [:resolve "$duckdnsFullDomain"]
    /ip firewall address-list remove [find where comment="public"]

#   Get the current IP on the WAN interface.
    :local currentIP [/ip address get [find interface="$wanInterface" disabled=no] address]

#   Strip net mask from IP address.
    :for i from=([:len $currentIP] - 1) to=0 do={
        :if ([:pick $currentIP $i] = "/") do={
            :set currentIP [:pick $currentIP 0 $i]
        }
    }

    :log info "DuckDNS: DNS IP ($previousIP), interface IP ($currentIP)"
    
    :if ($currentIP != $previousIP) do={
        :log info "DuckDNS: Current IP $currentIP is not equal to previous IP, update needed"
        :log info "DuckDNS: Sending update for $hostname"
        /tool fetch mode=https keep-result=yes dst-path=($logDestination . "duckdns-ddns-update.txt") address=[:resolve www.duckdns.org] port=443 host=www.duckdns.org src-path=("/update?domains=" . $duckdnsSubDomain . "&token=" . $duckdnsToken . "&ip=" . $currentIP);
        /ip firewall address-list add list=public address="$currentIP"  comment=public
        :log info "DuckDNS: Host $hostname updated on DuckDNS with IP $currentIP"
    }   else={
        :log info "DuckDNS: Previous IP $previousIP is equal to current IP, no update needed"
        /ip firewall address-list add list=public address="$previousIP"  comment=public
        }

}   else={
    :log info "DuckDNS: $wanInterface is not currently running, unable to verify and/or update IP."
    }
    
:log warning message="END: DuckDNS.org DDNS Update"

Perlunya Website Company Profile

Website Company Profile  Website company profile adalah alat pemasaran yang penting bagi setiap bisnis. Ini berfungsi sebagai brosur digital yang memberikan informasi tentang sejarah perusahaan,

Read More »

Elementor Apaan Siy??

Elementor adalah plugin WordPress Elementor adalah plugin WordPress yang memungkinkan pengguna untuk membuat tampilan dan desain halaman web mereka dengan cara yang mudah dan cepat.

Read More »