A lightweight, Docker-packaged Dynamic DNS service that automatically updates one or more A-records in AWS Route 53 via a simple HTTP endpoint. Perfect for home networks, small offices, or any environment with a dynamic IP address that needs reliable DNS resolution.
- π Multiple DNS Records: Update multiple domain names simultaneously with a single API call
- πΎ Stateful Operation: Remembers the last known IP to avoid unnecessary AWS API calls and reduce costs
- π³ Fully Containerized: Runs in an isolated Docker container with Docker Compose for easy deployment
- βοΈ Environment-Based Configuration: All settings managed via environment variables - no code changes needed
- π Comprehensive Logging: Rotating log files with detailed request tracking and error reporting
- π Secure: Uses AWS IAM credentials for secure Route 53 access
- β‘ Lightweight: Minimal resource footprint with Python Flask backend
Before deploying this service, ensure you have the following:
- Docker (version 20.10 or higher)
- Docker Compose (version 2.0 or higher)
- AWS Account with Route 53 access
- AWS IAM User with Route 53 permissions
Your AWS IAM user needs the following Route 53 permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["route53:ChangeResourceRecordSets", "route53:GetChange"],
"Resource": [
"arn:aws:route53:::hostedzone/*",
"arn:aws:route53:::change/*"
]
}
]
}git clone https://github.com/mainvoid007/dyndns.git
cd dyndnsCreate a .env file in the project root:
# AWS Configuration
AWS_ACCESS_KEY_ID=your_aws_access_key_here
AWS_SECRET_ACCESS_KEY=your_aws_secret_key_here
AWS_DEFAULT_REGION=eu-west-1
# Route 53 Configuration
HOSTED_ZONE_ID=Z1234567890ABCDEFGHIJ
RECORD_NAMES=subdomain1.yourdomain.com,subdomain2.yourdomain.com
# Service Configuration
HOST_PORT=8005| Variable | Description | Example |
|---|---|---|
AWS_ACCESS_KEY_ID |
Your AWS access key | AKIAIOSFODNN7EXAMPLE |
AWS_SECRET_ACCESS_KEY |
Your AWS secret key | wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY |
AWS_DEFAULT_REGION |
AWS region for Route 53 | eu-west-1, us-east-1 |
HOSTED_ZONE_ID |
Route 53 hosted zone ID | Z1234567890ABCDEFGHIJ |
RECORD_NAMES |
Comma-separated list of DNS records | home.yourdomain.com,office.yourdomain.com |
HOST_PORT |
Port to expose the service on | 8005 |
# Build and start the service
docker-compose up -d
# Check service status
docker-compose ps
# View logs
docker-compose logs -fcurl http://localhost:8005/Response: DynDNS Service is active.
curl "http://localhost:8005/update?ip=203.0.113.1"Response Examples:
β Success:
{
"status": "success",
"ip": "203.0.113.1"
}π No Change:
{
"status": "no_change",
"ip": "203.0.113.1"
}β Error:
{
"status": "error",
"message": "Missing 'ip' parameter."
}Add this to your router's startup script:
# Get current WAN IP and update DNS
WAN_IP=$(curl -s ifconfig.me)
curl -s "http://your-server:8005/update?ip=$WAN_IP"# Add to crontab (runs every 5 minutes)
*/5 * * * * curl -s "http://localhost:8005/update?ip=$(curl -s ifconfig.me)" > /dev/null 2>&1$ip = (Invoke-WebRequest -Uri "https://ifconfig.me" -UseBasicParsing).Content
Invoke-WebRequest -Uri "http://localhost:8005/update?ip=$ip" -UseBasicParsing# Real-time logs
docker-compose logs -f
# Recent logs
docker-compose logs --tail=100- Application Logs:
logs/requests.log - State File:
logs/last_ip.log
2024-01-15 10:30:45,123 - INFO - Update request from IP 192.168.1.100 with parameters: {'ip': '203.0.113.1'}
2024-01-15 10:30:45,456 - INFO - IP address change detected: Old IP=203.0.113.0, New IP=203.0.113.1
2024-01-15 10:30:46,789 - INFO - Route 53 and state successfully updated to 203.0.113.1
# Check Docker logs
docker-compose logs
# Verify environment variables
docker-compose config- Verify your AWS credentials in the
.envfile - Ensure your IAM user has Route 53 permissions
- Check that the AWS region is correct
- Verify the
HOSTED_ZONE_IDis correct - Ensure
RECORD_NAMESare properly formatted (comma-separated) - Check that the domain names exist in your Route 53 hosted zone
To run in debug mode, modify the Dockerfile:
CMD ["python", "app.py", "--debug"]- Never commit your
.envfile - it's already in.gitignore - Use IAM roles instead of access keys when possible
- Restrict network access to the service port
- Regularly rotate your AWS credentials
- Monitor AWS CloudTrail for API usage
- Stateful operation prevents unnecessary API calls
- Rotating logs prevent disk space issues
- Lightweight container minimizes resource usage
- Efficient Route 53 updates using batch operations
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the troubleshooting section
- Review the logs using
docker-compose logs - Open an issue on GitHub with detailed information
Made with β€οΈ for the community