Last active
September 14, 2023 11:53
-
-
Save wannadrunk/e1438628b88c2fcae6c006ff067efae7 to your computer and use it in GitHub Desktop.
Revisions
-
wannadrunk renamed this gist
Sep 14, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
wannadrunk created this gist
Sep 14, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ # Mikrotik Script for loop until get the public IP from NT # and then set DNS A record to that public IP. # # Update WANIF to match your interface name. And all CloudFlare required key and info. # # Put this into the ppp profile UP script and assign to pppoe connection # :local WANIF "pppoe-1"; :while ( $"local-address" in 100.64.0.0/10 ) do={ :log warning ("$WANIF: Got Private IP ".$"local-address"." Reconnecting the interface..."); /interface pppoe-client disable $WANIF; :delay 10s; /interface pppoe-client enable $WANIF; }; :log info ("$WANIF: Got IP ".$"local-address"); :local IP4NEW $"local-address" # Cloudflare Dynamic DNS update script # Required policy: read, write, test, policy # Configuration --------------------------------------------------------------------- :local TOKEN "__TokenAPI__" :local ZONEID "__ZoneID__" :local RECORDID "__RecordID__" :local RECORDNAME "__SubDomainName__" #------------------------------------------------------------------------------------ :local url "https://api.cloudflare.com/client/v4/zones/$ZONEID/dns_records/$RECORDID/" :local cfapi [/tool fetch http-method=put mode=https url=$url check-certificate=no output=user as-value \ http-header-field="Authorization: Bearer $TOKEN,Content-Type: application/json" \ http-data="{\"type\":\"A\",\"name\":\"$RECORDNAME\",\"content\":\"$IP4NEW\",\"ttl\":120,\"proxied\":false}"] :log info "CF-DDNS: Host $RECORDNAME updated with IP $IP4NEW"