Skip to content

hyprsoftcorp/DnsMonitor

Repository files navigation

Introduction

This .NET 8 "worker" background service monitors your public IP address for changes and updates the appropriate DNS records to allow remote access to your home/office network. It performs very basic functions similar to changeip.com, dyndns.com, easydns.com, and no-ip.com.

Getting Started

This service must be run inside your home/office network, not in the cloud.

Since .NET 8 supports a number of operating systems, this app can be run almost anywhere. In our test case we are running this service on a Raspberry PI 4 (4GB) using the Rasberry PI OS Lite (Bullseye). The service ensures that anytime our public IP address changes, our DNS records are automatically updated so that we can always access various services on our network from anywhere in the world.

Supported Public IP Address Providers

  1. IpifyPublicIpProvider - No authentication required and is free.
  2. HyprsoftPublicIpProvider - Requires an API key and secret.

Supported DNS Providers

  1. HyprsoftDnsProvider - No authentication required and can be used for testing. This provider returns random IP addresses.
  2. GoDaddyDnsProvider - Requires a GoDaddy API key and secret.

Sample Settings File

The 'appsettings.json' file is required and here is a sample. This file COULD contain sensitive/secret information. Protect it accordingly!

{
  "MonitorSettings": {
    "Domains": [ "www.hyprsoft.com" ],
    "DnsProviderApiCredentials": {
      "ProviderKey": "HyprsoftDnsProvider",
      "ApiKey": null,
      "ApiSecret": null
    },
    "PublicIpProviderApiCredentials": {
      "ProviderKey": "IpifyPublicIpProvider",
      "ApiKey": null,
      "ApiSecret": null
    },
    "CheckIntervalMinutes": 10
  }
}

Docker Setup

See our Docker Hub for more details. Make sure to adjust your host volume mapping file path for the 'appsettings.json' file.

Linux (amd64)

docker run -it -d --name dnsmonitor --restart always -v C:\Docker\dnsmonitor\appsettings.json:/app/appsettings.json hyprsoft/hyprsoft.dns.monitor:1.3.2-linux-amd64

Linux (arm64)

docker run -it -d --name dnsmonitor --restart always -v /home/pi/dnsmonitor/appsettings.json:/app/appsettings.json hyprsoft/hyprsoft.dns.monitor:1.3.2-linux-arm64

Automatic Service Startup on Linux

Create a dnsmonitor.service file using:

sudo nano /etc/systemd/system/dnsmonitor.service

Sample dnsmonitor.service

This assumes the service binaries have been copied to the '/usr/bin/dnsmonitor' directory.

[Unit]
Description=Hyprsoft Dns Monitor
After=network.target
Require=network.target

[Service]
ExecStart=/usr/bin/dnsmonitor/Hyprsoft.Dns.Monitor
WorkingDirectory=/usr/bin/dnsmonitor/

[Install]
WantedBy=multi-user.target

Start the DNS monitor service:

sudo systemctl enable dnsmonitor.service
sudo systemctl daemon-reload
sudo systemctl start dnsmonitor.service

Troubleshooting

sudo systemctl status dnsmonitor.service
sudo nano /usr/bin/dnsmonitor/app-log.log

Service Startup on Windows IoT Core

schtasks /create /tn "Hyprsoft DNS Monitor" /tr c:\hyprsoft\dnsmonitor\Hyprsoft.Dns.Monitor.exe /sc onstart /ru System

See scheduled tasks for more information.

Architecture

The architecture allows contributors to easily add additional public IP address and DNS providers by simply deriving from PublicIpProvider or DnsProvider and implementing the GetPublicIPAddressAsync() method or the GetDnsIPAddressAsync() and SetDnsIPAddressAsync() methods.

About

An app to monitor your public IP address for changes and update DNS records accordingly.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published