A .NET 9 background service that automatically updates DNS records in Netlify when your public IP address changes. Perfect for self-hosted services that need to maintain up-to-date DNS records without a static IP address.
- π Automatic IP Detection: Monitors your public IP address using the ipify API
- π Netlify DNS Integration: Updates DNS records via Netlify's REST API
- π³ Docker Support: Containerized application ready for deployment
- βοΈ Environment Variable Configuration: Override settings without rebuilding
- π Comprehensive Logging: Detailed logging for monitoring and debugging
- π Secure Token Handling: Access tokens are masked in logs for security
- The service polls the ipify API every minute to check your current public IP address
- When an IP change is detected, it queries Netlify for DNS zones matching your configured domain
- Updates all non-managed DNS records in the zone with the new IP address
- Continues monitoring for future IP changes
- .NET 9.0 Runtime (for local development)
- Docker/Podman (for containerized deployment)
- Netlify account with DNS management enabled
- Netlify Personal Access Token
- Log in to your Netlify account
- Go to User Settings > Personal Access Tokens
- Click "New access token"
- Give it a descriptive name and create the token
- Copy the token (starts with
nfp_)
The application can be configured via appsettings.json or environment variables:
{
"Ipify": {
"Endpoint": "https://api.ipify.org"
},
"Netlify": {
"Endpoint": "https://api.netlify.com/api/v1",
"Domain": "your-domain.com",
"AccessToken": "your-netlify-token"
},
"Logging": {
"LogLevel": {
"Default": "Debug"
}
}
}Ipify__Endpoint: ipify API endpoint (default: https://api.ipify.org)Netlify__Endpoint: Netlify API endpoint (default: https://api.netlify.com/api/v1)Netlify__Domain: Your domain name (e.g.,example.com)Netlify__AccessToken: Your Netlify Personal Access TokenLogging__LogLevel__Default: Log level (Debug, Information, Warning, Error)
-
Build the container:
# From the solution root directory docker build -f OakTech.DynamicDns.Netlify/Dockerfile -t oaktech-dynamic-dns .
-
Run with environment variables:
docker run -e Netlify__AccessToken=your_token_here \ -e Netlify__Domain=your-domain.com \ oaktech-dynamic-dnsOr with Podman:
podman run -e Netlify__AccessToken=your_token_here \ -e Netlify__Domain=your-domain.com \ oaktech-dynamic-dns
-
Clone and restore:
git clone <repository-url> cd OakTech.DynamicDns.Netlify dotnet restore
-
Configure appsettings.json or use user secrets:
dotnet user-secrets set "Netlify:AccessToken" "your_token_here" dotnet user-secrets set "Netlify:Domain" "your-domain.com"
-
Run the application:
cd OakTech.DynamicDns.Netlify dotnet run
OakTech.DynamicDns.Netlify/
βββ Clients/ # API client interfaces and models
β βββ IIpifyApi.cs # ipify API client interface
β βββ INetlifyApi.cs # Netlify API client interface
β βββ DnsEntryRequest.cs # DNS record request model
β βββ DnsEntryResponse.cs # DNS record response model
β βββ DnsForSiteResponse.cs # DNS zone response model
β βββ IpifyResponse.cs # IP address response model
βββ Options/ # Configuration option classes
β βββ IpifyOptions.cs # ipify API configuration
β βββ NetlifyOptions.cs # Netlify API configuration
βββ Services/ # Business logic services
β βββ DomainManagementService.cs # Main background service
βββ Program.cs # Application entry point
βββ appsettings.json # Configuration file
βββ Dockerfile # Container build instructions
- Microsoft.Extensions.Hosting (9.0.8) - Background service framework
- Refit (8.0.0) - HTTP API client library
- Refit.HttpClientFactory (8.0.0) - HttpClient integration
- π Access tokens are masked in log output (shows first 4 and last 4 characters only)
- π« Never commit access tokens to source control
- π Use environment variables or user secrets for sensitive configuration
- π Regularly rotate your Netlify access tokens
-
"No managed DNS zone found"
- Ensure your domain is correctly configured in Netlify DNS
- Verify the domain name matches exactly (case-sensitive)
-
"Access Token changeme"
- Check that environment variables are passed correctly to the container
- Ensure you're using double underscores (
__) in environment variable names - Verify the container was rebuilt after adding
.AddEnvironmentVariables()
-
API Authentication Errors
- Verify your Netlify access token is valid and hasn't expired
- Check that the token has the necessary permissions for DNS management
The application provides detailed logging. Key log messages include:
- Service startup with masked access token
- IP address changes detection
- DNS record updates
- API errors and exceptions
This project is licensed under the MIT License.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For issues and questions, please open an issue in the GitHub repository.