Persiapan
Akun Cloudflare. API Key, Zona ID dan ID Record. RouterBoard menjalankan RouterOS versi 6.44 atau lebih tinggi.
Script Untuk Update Otomatis DDNS No-IP DNS – Solusi IP Dynamic Indihome
Langkah
Buat akun Cloudflare
Apabila anda belum mempunyai akun cloudflare silahkan daftar terlebih dahulu di halaman https://www.cloudflare.com .
Gunakan email yang aktif untuk mendaftar
Tambahkan sebuah domain
Pilih yang gratis saja dulu, karena kita hanya mencobanya untuk belajar 😀
Daftar DNS Record akan ditampilkan. Klik Continue untuk melanjutkan.
Ganti nameserver default domain anda dengan nameserver yang disediakan oleh cloudflare
Simpanlah API Key, Zone ID and Record ID
Caranya buka avatar yang berada di pojok kanan atas lalu klik My Profile.
Scrol kebawah disana ada Global API Key lalu pilihlah View untuk melihat API Keys anda.
Masukkan password akun clodflare anda, setelah pasword dimasukkan dengan benar API Keys akan muncul, simpan baik-baik API Keys tersebut.
Buka home lalu pilih domain yang sudah di daftarkan ke cloudflare, nanti di overview terdapat ZONE ID, simpan ZONE ID tersebut.
Script Untuk Update Otomatis DDNS DigitalOcean – Solusi IP Dynamic Indihome
Jalankan script berikut di New Terminal winbox Mikrotik anda
global cfg do={\
/tool fetch mode=https\
http-method=get\
url="https://api.cloudflare.com/client/v4/zones/$cfi/dns_records"\
http-header-field="content-type:application/json,X-Auth-Email:$cfe,X-Auth-Key:$cfk"\
}
Jalankan juga script berikut di New Terminal winbox Mikrotik anda, sebelumnya ubah dulu email, api key dan zone id.
$cfg cfi="ZONE ID" cfe="EMAIL CLOUDFLARE" cfk="API KEY"
Setelah kedua script tersebut dijalankan, akan terdapat file baru di file manager winbox
Buka file dan secara manual dapatkan RECORD ID yang diinginkan atau gunakan tools ini untuk mendapatkannya.
Langkah terakhir jalankan script berikut di New Terminal winbox Mikrotik anda
Share to Unlock Content
image/svg+xml
Silahkan share untuk membuka link download dan membuka scriptnya
Apabila tutorial ini bermanfaat support saya dengan cara share artikel ini..
Terimakasih
:global cfu do={\
:local cfi "ZONE_ID";\
:local cfr "RECORD_ID";\
:local cfe "EMAIL_ADDRESS";\
:local cfk "API_KEY";\
:local cfd "RECORD_DOMAIN";\
:local cfa [/ip cloud get public-address];\
:local cfp true;\
/tool fetch mode=https\
http-method=put\
url="https://api.cloudflare.com/client/v4/zones/$cfi/dns_records/$cfr"\
http-header-field="content-type:application/json,X-Auth-Email:$cfe,X-Auth-Key:$cfk"\
http-data="{\"type\":\"A\",\"name\":\"$cfd\",\"content\":\"$cfa\",\"proxied\":$cfp}"\
output=none\
}
Anda juga bisa menggunakan script alternatif berikut ini untuk update ddns cloudflare:
Share to Unlock Content
image/svg+xml
Silahkan share untuk membuka link download dan membuka scriptnya
Apabila tutorial ini bermanfaat support saya dengan cara share artikel ini..
Terimakasih
#########################################################################
# ================================================== #
# $ Mikrotik RouterOS update script for CloudFlare $ #
# ================================================== #
# #
# - You need a CloudFlare account & api key (look under settings), #
# a zone and A record in it #
# - All variables in first section are obvious, except CFid, #
# To obtain CFzoneid use following command in any unix shell: #
# curl -X GET "https://api.cloudflare.com/client/v4/zones" -H "X-Auth-Email: YOUR_EMAIL" -H "X-Auth-Key: YOUR_API_KEY" -H "Content-Type: application/json" | python -mjson.tool
# To obtain CFid use following command in any unix shell: #
# curl -X GET "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/dns_records" -H "X-Auth-Email: YOUR_EMAIL" -H "X-Auth-Key: YOUR_API_KEY" -H "Content-Type: application/json" | python -mjson.tool
# - Enable CFDebug if needed - it'll print some info to logs #
# - Put script under /system scripts giving "read,write,ftp" policy access. #
# For 6.29 and older "test" policy is also needed. #
# - Add script to /system scheduler using it's name in "on-event" #
# - Requires at least RouterOS 6.44beta75 for multiple header support #
# #
# Credits for Samuel Tegenfeldt, CC BY-SA 3.0 #
# Modified by kiler129 #
# Modified by viritt #
# Modified by asuna #
#########################################################################
################# CloudFlare variables #################
:local CFDebug "true"
:global WANInterface "ether1-gateway"
:local CFdomain "sub.domain.com"
:local CFzone "domain.com"
:local CFemail "[email protected] "
:local CFtkn "YOUR_API_KEY"
:local CFzoneid "YOUR_ZONE_ID"
:local CFid "YOUR_ID"
:local CFrecordType ""
:set CFrecordType "A"
:local CFrecordTTL ""
:set CFrecordTTL "120"
#########################################################################
######################## DO NOT EDIT BELOW ############################
#########################################################################
################# Internal variables #################
:local previousIP ""
:global WANip ""
################# Get or set previous IP-variables #################
:local currentIP [/ip address get [/ip address find interface=$WANInterface ] address];
:set WANip [:pick $currentIP 0 [:find $currentIP "/"]];
:if ([/file find name=ddns.tmp.txt] = "") do={
:log error "No previous ip address file found, createing..."
:set previousIP $WANip;
:execute script=":put $WANip" file="ddns.tmp";
:log info ("CF: Updating CF, setting $CFDomain = $WANip")
/tool fetch http-method=put mode=https output=none url="$CFurl" http-header-field="X-Auth-Email:$CFemail,X-Auth-Key:$CFtkn,content-type:application/json" http-data="{\"type\":\"$CFrecordType\",\"name\":\"$CFdomain\",\"ttl\":$CFrecordTTL,\"content\":\"$WANip\"}"
:error message="No previous ip address file found."
} else={
:if ( [/file get [/file find name=ddns.tmp.txt] size] > 0 ) do={
:global content [/file get [/file find name="ddns.tmp.txt"] contents] ;
:global contentLen [ :len $content ] ;
:global lineEnd 0;
:global line "";
:global lastEnd 0;
:set lineEnd [:find $content "\n" $lastEnd ] ;
:set line [:pick $content $lastEnd $lineEnd] ;
:set lastEnd ( $lineEnd + 1 ) ;
:if ( [:pick $line 0 1] != "#" ) do={
#:local previousIP [:pick $line 0 $lineEnd ]
:set previousIP [:pick $line 0 $lineEnd ];
:set previousIP [:pick $previousIP 0 [:find $previousIP "\r"]];
}
}
}
################# Build CF API Url (v4) #################
:local CFurl "https://api.cloudflare.com/client/v4/zones/"
:set CFurl ($CFurl . "$CFzoneid/dns_records/$CFid");
######## Write debug info to log #################
:if ($CFDebug = "true") do={
:log info ("CF: hostname = $CFdomain")
:log info ("CF: previousIP = $previousIP")
:log info ("CF: currentIP = $currentIP")
:log info ("CF: WANip = $WANip")
:log info ("CF: CFurl = $CFurl&content=$WANip")
:log info ("CF: Command = \"/tool fetch http-method=put mode=https url=\"$CFurl\" http-header-field=\"X-Auth-Email:$CFemail,X-Auth-Key:$CFtkn,content-type:application/json\" output=none http-data=\"{\"type\":\"$CFrecordType\",\"name\":\"$CFdomain\",\"ttl\":$CFrecordTTL,\"content\":\"$WANip\"}\"")
};
######## Compare and update CF if necessary #####
:if ($previousIP != $WANip) do={
:log info ("CF: Updating CF, setting $CFDomain = $WANip")
/tool fetch http-method=put mode=https url="$CFurl" http-header-field="X-Auth-Email:$CFemail,X-Auth-Key:$CFtkn,content-type:application/json" output=none http-data="{\"type\":\"$CFrecordType\",\"name\":\"$CFdomain\",\"ttl\":$CFrecordTTL,\"content\":\"$WANip\"}"
/ip dns cache flush
:if ( [/file get [/file find name=ddns.tmp.txt] size] > 0 ) do={
/file remove ddns.tmp.txt
:execute script=":put $WANip" file="ddns.tmp"
}
} else={
:log info "CF: No Update Needed!"
}
download script
Buka file dan secara manual dapatkan RECORD ID yang diinginkan atau gunakan tools ini untuk mendapatkannya , tolong di perjelas bab ini om… makasih
di File Manager Mikrotik terdapat file dns_records, nah pindahkan secara file tersebut ke komputer lalu buka dan cari RECORD ID
gimana cara buka file dns recordnya. saya ikutin yg di gambar ga muncul apa apa
RECORD ID
buka dns record nya pake apa ya ?