Skip to content

Support for adding a comment to the DNS record #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ rename the folder to _DDNS-Cloudflare-PowerShell_ place in a directory of your c

Update the config parameters inside the update-cloudflare-dns_conf.ps1 by editing accordingly. See below for examples.

| **Option** | **Example** | **Description** |
| ------------------------- | ---------------- | --------------------------------------------------------- |
| what_ip | internal | Which IP should be used for the record: internal/external |
| dns_record | ddns.example.com | DNS **A** record which will be updated |
| cloudflare_zone_api_token | ChangeMe | Cloudflare API Token **KEEP IT PRIVATE!!!!** |
| zoneid | ChangeMe | Cloudflare's Zone ID |
| proxied | false | Use Cloudflare proxy on dns record true/false |
| ttl | 120 | 120-7200 in seconds or 1 for Auto |
| **Option** | **Example** | **Description** |
| ------------------------- | ---------------------------------------- | --------------------------------------------------------- |
| what_ip | internal | Which IP should be used for the record: internal/external |
| dns_record | ddns.example.com | DNS **A** record which will be updated |
| cloudflare_zone_api_token | ChangeMe | Cloudflare API Token **KEEP IT PRIVATE!!!!** |
| zoneid | ChangeMe | Cloudflare's Zone ID |
| proxied | false | Use Cloudflare proxy on dns record true/false |
| ttl | 120 | 120-7200 in seconds or 1 for Auto |
| comment | Updated using DDNS-Cloudflare-PowerShell | For record keeping, no effect on DNS itself |

### Optional Notifications Parameters for Telegram

Expand Down
5 changes: 3 additions & 2 deletions update-cloudflare-dns.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ $cloudflare_record_info = @{

$cloudflare_record_info_resposne = Invoke-RestMethod -Proxy $http_proxy -ProxyCredential $proxy_credential @cloudflare_record_info
if ($cloudflare_record_info_resposne.success -ne "True") {
Write-Output "Error! Can't get $dns_record record inforamiton from cloudflare API" | Tee-Object $File_LOG -Append
Write-Output "Error! Can't get $dns_record record information from cloudflare API" | Tee-Object $File_LOG -Append
Exit
}

Expand All @@ -181,6 +181,7 @@ $update_dns_record = @{
"content" = $ip
"ttl" = $ttl
"proxied" = $proxied
"comment" = $comment
} | ConvertTo-Json
}

Expand All @@ -191,7 +192,7 @@ if ($update_dns_record_response.success -ne "True") {
}

Write-Output "==> Success!" | Tee-Object $File_LOG -Append
Write-Output "==> $dns_record DNS Record Updated To: $ip, ttl: $ttl, proxied: $proxied" | Tee-Object $File_LOG -Append
Write-Output "==> $dns_record DNS Record Updated To: $ip, ttl: $ttl, proxied: $proxied. `ncomment: $comment" | Tee-Object $File_LOG -Append


if ($notify_me_telegram -eq "no" -And $notify_me_discord -eq "no") {
Expand Down
8 changes: 5 additions & 3 deletions update-cloudflare-dns_conf.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@

## Which IP should be used for the record: internal/external
## Internal interface will be chosen automaticly as a primary default interface
$what_ip = "internal"
$what_ip = "external"
## DNS A record to be updated
$dns_record = "ddns.example.com"
## Use IPv6
$IPv6 = $false
## if use DoH to query the current IP address
$DNS_over_HTTPS = $false
## Cloudflare's Zone ID
## Cloudflare's Zone ID - Cloudflare Dashboard -> Websites -> example.com -> Overview -> API Zone ID on right-hand sidebar
$zoneid = "ChangeMe"
## Cloudflare Zone API Token
## Cloudflare Zone API Token - Instructions: https://github.com/fire1ce/DDNS-Cloudflare-PowerShell/blob/main/README.md#creating-cloudflare-api-token
$cloudflare_zone_api_token = "ChangeMe"
## Use Cloudflare proxy on dns record true/false
$proxied = $false
## Comment to put on the updated record
$comment = "Updated with fire1ce's DDNS-Cloudflare-PowerShell script $((Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ'))"
## 60-7200 in seconds or 1 for Auto
$ttl = 120

Expand Down