How to Configure YDNS Dynamic DNS on Windows Server

This guide shows you how to set up YDNS dynamic DNS on a Windows Server with a dynamic IP. We will create a PowerShell script that will update our IP to YDNS, and make a schedule task to run the script every 5 minutes.

YDNS is a free, Germany-based, GDPR compliant, privacy-focused, security-centric DDNS service with DNSSEC support.

1. Set Up YDNS

  • Sign up at ydns.eu.
  • Log in, go to “Hosts”, and click “New Host”.
  • Name: Pick a desired hostname.
  • Content: Enter your external IP address.
  • Click “Create Host”.
  • Click the host and pick “Get Update URL” to get your unique update URL(e.g., https://ydns.io/hosts/update/your_token).

2. Create Update Script

Start by creating the folder C:\Scripts\Scheduled through PowerShell, that will hold our script:

New-Item -Path "C:\Scripts\Scheduled" -ItemType Directory -Force

Open a text editor and past the following script.
Replace your_token with the token from your YDNS “Update URL.”:

$updateUrl = "https://ydns.io/hosts/update/your_token"
Invoke-RestMethod -Uri $updateUrl -Method Get

Save as Update-YDNS.ps1 in C:\Scripts\Scheduled.

3. Schedule the Script to Run Every 5 Minutes

Run this command in PowerShell:

$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File C:\Scripts\Scheduled\Update-YDNS.ps1"
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 5)
$trigger.Repetition.Duration = $null
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -RunOnlyIfNetworkAvailable
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
Register-ScheduledTask -TaskName "UpdateYDNS" -Action $action -Trigger $trigger -Description "Updates YDNS IP every 5 minutes" -Principal $principal -Settings $settings -Force

4. Verify the Scheduled Task

Check Task Scheduler to confirm the “UpdateYDNS” task is listed, or verify the scheduled task from PowerShell:

Get-ScheduledTask -TaskName "UpdateYDNS"

To check if it’s running as expected, view its last run result:

Get-ScheduledTaskInfo -TaskName "UpdateYDNS"

That’s it. Your server’s IP will now update on YDNS every 5 minutes (if there is a change), keeping your server accessible.

Categories: Server