發表文章

目前顯示的是有「DDNS」標籤的文章

使用批次檔來更新 cloudflare DDNS

 不熟批次檔(.bat/.cmd),但是家人不可能用 Linux ,還是得客製一下,能動為準 工作環境:     Windows Home          .bat          工作排程器          curl          python(沒有的話,輸出的結果會粘在一起) token varify 確認 apiToken 是正確的 curl "https://api.cloudflare.com/client/v4/user/tokens/verify" -H "Authorization : Bearer tokenHere" get zoneID 把 zoneID 記下來 curl -X GET "https://api.cloudflare.com/client/v4/zones" -H "Authorization : Bearer tokenHere" -H "Content-Type:application/json" get dns records 找到你要更新的網址名稱 name(FQDN,不是zone_name),把它的 id(不是zone_id) 記下來 curl -X GET "https://api.cloudflare.com/client/v4/zones/zoneIDHere/dns_records" -H "authorization : Bearer tokenHere" -H "Content-Type:application/json" | c:\somewhere\python -m json.tool target dns record to update(.bat)************ curl ipinfo.io/ip > ip.txt set /p IP=<ip.txt curl -X PUT "https://api.cloudflare.com/client/v4/zones/zoneIDHere/dns_...

使用 shell script 更新 cloudflare 的 DNS 記錄

 記錄一下使用 shell script 更新 cloudflare 的 DNS 記錄(DDNS)  工作環境:     Linux          curl          jq 使用 curl 和 cloudflare API 溝通,就可以達成更新 DNS 記錄的目的,基本上就是提供 zone ID 和 API Token 給 cloudflare ,指定要更新的域名(FQDN),當然,要抓到目前使用的「對外」的 IP 位址一併提供  範例:updateCfDDNS flkjfldajldfj ddns.your.domain lfkdalfjldjf;lajd;lf #!/bin/sh # update DDNS records with curl using cloudflare API # input: zoneID, FQDN, APIToken, get internet IP addr. # output: none but DNS record update dynamicly # pre-requirements: config cloudflare API token # post-requirement: config crontab to update DDNS regularly # usage: updateCfDDNS zoneID FQDN APIToken if [ -z $1 ]         then                 echo "please provide zoneId, fqdn, apiToken, thank you..." else MYIP = ` curl https://ipinfo.io/ip` RECID = ` curl -X GET "https://api.cloudflare.com/client/v4/zones/ ${1} /dns_records?name= ${2...

據說 cloudflare 也是可以用 ddns 的

 實作在 mikrotik 上更新 cloudflare ddns ip ,原來只要開通 cloudflare api 就行…… 單藍,要再加些楜椒和鹽… 工作環境:  Linux Shell  Mikrotik routerOS  cloudflare API # 建立更新 cloudflare DNS 記錄用的 API Token # create API Token in cloudflare The TOKEN value is created in the Cloudflare dashboard. Follow these steps: 1.  Click the profile icon in the top right of the dashboard, and choose 'My Profile' . 2.  Click on 'API Tokens' , then 'Create Token' . 3.  Click 'Start with a template' , then choose the 'Edit zone DNS' template. 4.  Under 'Zone Resources' , choose your top level domain name from the pull-down list on the right. 5.  Click 'Continue to summary' . 6.  Click 'Create Token' . 7.  Copy the token shown on the following screen and set the TOKEN environment variable to its value. # 更新 cloudflare DNS 紀錄會用到的變數 # 參考資料說要用 direnv 因為除錯失敗,直接把變數放到 gen_script 裏了…… # Variables needed for updating cloudflare DNS records HOST =api.cloudflare.com DOMAIN =yourDomain.n...

在 Mikrotik 上更新 cloudflare 的 DDNS 記錄

 提供 DDNS 的服務商有很多,其實如果你用 M 家的機器,啟動後就有 DDNS 可以用,只是買了服務商的網域名稱,掛上自已的名字來用,所以得來折騰一下。   工作環境:     Mikrotik wifi router          DDNS update script     cloudflare DNS manager  參照 既有的 script ,到 dash > 概觀裏把 zone ID,你要更新的 domain (其實是 hostname / FQDN) ,再到 profile 裏把 API token for DNS ,TTL 這些參數找到,等一下設定 script 要用,然後在 cloudflare DNS manager 裏,把你要設的 A record 記錄,指到「 不正確 」的 IP,由於這個方式只適用非 proxy 的狀態( 僅DNS ),剛好合用, proxy 的部份就不折騰了,留給能人去試 XD,以上是和 cloudflare 相關的設定部份  回到 M 家的 wifi router 上,把剛才的收集到的參數在腳本裏改好,將改好的 script 貼到 system > scirpt list > name: DDNS > policy: read,write,test > source(貼上改好的腳本) > apply > run script ,以上是和 M 家 wifi router 相關的部份  如果你回到你的 cloudflare DNS manager 裏,你的 A 記錄和 TTL 更新了,恭喜你,成功了!  收工!    參考資料 / 資源: https://github.com/mike6715b/Mikrotik_CF_DDNS/blob/main/CF-Update.rsc  cloudflare > dash > profile cloudflare > profile > API > token