Mikrotik Duckdns.org Update (New Script)

In Mikrotik, Tutorial 871 views


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"

Related Search

Tags: #duckdns #dynamic ip public #ip public #mikrotik

Install Pi-Hole DNS Blokir Iklan dan Tracker
Install Pi-Hole DNS Blokir Iklan dan Tracker
Pi-Hole merupakan salah satu pelindung user internet
Migrasi VPS Panel dari Tuxlite ke VestaCP
Migrasi VPS Panel dari Tuxlite ke VestaCP
Setelah sekian lama menggunakan Tuxlite akhirnya diputuskan
Cara Cepat Root Unlock STB ZTE B760H Tanpa Bongkar
Cara Cepat Root Unlock STB ZTE B760H Tanpa Bongkar
Mungkin beberapa ada yang pernah berlangganan Indihome
Upgrade PHP 5.6 ke PHP 7.0 Nginx Debian Jessie
Upgrade PHP 5.6 ke PHP 7.0 Nginx Debian Jessie
Sebetulnya sudah agak lama warning untuk upgrade

Top