/cloudflareDDNS-PowerShell

Cloudflare DDNS PowerShell Script for Windows OS. Choose any source IP address to update external or internal (WAN/LAN). Cloudflare's options proxy and TTL configurable via the parameters.

Primary LanguagePowerShell

Cloudflare DDNS - Simple PowerShell Script

contributions welcome MIT license

Cloudflare DDNS PowerShell for Windows.
Choose any source IP address to update external or internal (WAN/LAN).
Cloudflare's options proxy and TTL configurable via the parameters.
Bash Script for Linux and MacOS can be found here

Requirements

  • api-token with ZONE-DNS-EDIT Permissions
  • DNS Record must be pre created (api-token should only edit dns records)
  • Enabled running unsigned PowerShell

Start Windows PowerShell with the "Run as Administrator" option and execute this command

set-executionpolicy remotesigned

Choose A for all

Installation

Download the cloudflareDDNS-PowerShell zip file & Unzip it

Extract to Personal Folder (C:\Users\USER)

Parameters

Update the config parameters at updateDNS6.ps1 by editing the file

Option Example Description
what_ip internal Which IP should be used for the record: internal/external
what_interface Ethernet0 For internal IP, provide interface name
dns_record ddns.example.com DNS A record which will be updated
zoneid ChangeMe Cloudflare's Zone ID
proxied false Use Cloudflare proxy on dns record true/false
ttl 1 120-7200 in seconds or 1 for Auto
cloudflare_api_token ChangeMe Cloudflare API Token KEEP IT PRIVATE!!!!

Running The Script

Right click on updateDNS.ps1 click Run with PowerShell

Automation With Windows Task Scheduler

Run At boot Example with the updateDNS.ps1 C:\Users\USER\cloudflareDDNS-PowerShell-main\updateDNS6.ps1:

  • Open Task Scheduler
  • Action -> Create Task
  • General Menu
    • Name: updateDNS
    • Run whether user is logged on or not
  • Trigger
    • New...
    • Begin the task: At startup
    • Delay Task for: 1 minute
    • Enabled
  • Actions
    • New...
    • Action: Start a Program
    • Program/script: Powershell
    • Add arguments (optional): -File C:\Users\USER\cloudflareDDNS-PowerShell-main\updateDNS6.ps1
    • ok
    • Enter your user's password when prompted

Logs

This Script will create a log file with only the last run information
Log file will be located as a hidden file at the same path as updateDNS.ps1

Log file name:

.updateDNS.log

License

MIT License

Copyright© 3os.org @2020

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.