Dynamic DNS automation tool for AWS Route 53. Monitors public IP changes and automatically updates DNS A records for configured domains. Features robust error handling, email notifications, logging, and prevents unnecessary updates.
- π Automatic public IP detection with multiple fallback services
- π Smart DNS record updates (only when IP changes or mismatches detected)
- π§ Email notifications on updates (optional)
- π Comprehensive logging with configurable levels
- βοΈ JSON-based configuration with environment variable support
- π‘οΈ Enhanced error handling with retry logic
- π Multiple domains/zones support
- π Security-focused with input validation and secure temp files
- π¦ Easy installation with automated installer
- π§ͺ Unit tests included
- Clone and install:
git clone https://github.com/bk86a/Route53DynamicIPUpdate.git cd Route53DynamicIPUpdate sudo ./install.sh # or ./install.sh for user installation
- Configure your domains:
cp hosts.json.example hosts.json
nano hosts.json # Add your domains and Route53 zone IDs- Configure settings:
cp config.env.example config.env
nano config.env # Set your email and preferences- Test the setup:
./update.sh
- Clone this repository:
git clone https://github.com/bk86a/Route53DynamicIPUpdate.git
cd Route53DynamicIPUpdate- Make the script executable:
chmod +x update.sh
- Configure your environment and domains (see Configuration section)
- AWS CLI installed and configured with Route 53 permissions
- jq for JSON parsing
- curl for IP detection
- msmtp for email notifications (optional)
Your AWS credentials need the following permissions:
{
"Version": "2012εΉ΄10ζ17ζ₯",
"Statement": [
{
"Effect": "Allow",
"Action": [
"route53:ListResourceRecordSets",
"route53:ChangeResourceRecordSets"
],
"Resource": "*"
}
]
}Copy config.env.example to config.env and customize:
# Email settings EMAIL="your-email@example.com" ENABLE_EMAIL_NOTIFICATIONS="true" # File paths HOSTS_JSON_FILE="./hosts.json" LOG_FILE="/var/log/route53_update.log" # IP detection with fallbacks PRIMARY_IP_SERVICE="http://checkip.amazonaws.com" FALLBACK_IP_SERVICES="https://ipinfo.io/ip https://api.ipify.org" # Retry configuration MAX_RETRIES="3" RETRY_DELAY="5" # Logging LOG_LEVEL="INFO" # DEBUG, INFO, WARN, ERROR ENABLE_STRUCTURED_LOGGING="false"
Copy hosts.json.example to hosts.json and add your domains:
{
"records": [
{
"name": "example.com",
"zone_id": "Z1234567890ABC",
"type": "A",
"ttl": 300
},
{
"name": "subdomain.example.com",
"zone_id": "Z1234567890ABC",
"type": "A",
"ttl": 300
}
]
}Fields:
name: The fully qualified domain namezone_id: Your Route 53 hosted zone IDtype: Record type (currently only "A" records are supported)ttl: Time-to-live in seconds
./update.sh
# Enable and start the timer (runs every 5 minutes) sudo systemctl enable --now route53-updater.timer # Check status sudo systemctl status route53-updater.timer # View logs journalctl -u route53-updater.service
# Edit crontab crontab -e # Add one of these lines: # Check every 5 minutes */5 * * * * /path/to/route53/update.sh >/dev/null 2>&1 # Check every hour 0 * * * * /path/to/route53/update.sh >/dev/null 2>&1
- IP Detection: Tries primary service, falls back to alternatives if needed
- Validation: Validates IP format and JSON configuration
- Change Detection: Compares with cached IP and current Route 53 records
- Dependency Check: Verifies all required tools are available
- Update Process: Updates only records that don't match current IP
- Retry Logic: Retries failed AWS API calls with exponential backoff
- Notification: Sends email summary of changes (if configured)
- Logging: Records all activities with configurable detail levels
update.sh- Main update scriptconfig.env- Configuration file (create from example)hosts.json- Domain configuration (create from example)install.sh- Automated installation scripttests/- Unit test suite/tmp/route53_current_ip.txt- Cached IP address (default location)/var/log/route53_update.log- Activity log (default location)
All activities are logged with timestamps and configurable levels:
2024εΉ΄09ζ22ζ₯ 10:30:15 - INFO: Current public IP: 203.0.113.42
2024εΉ΄09ζ22ζ₯ 10:30:16 - INFO: example.com: Already correct (203.0.113.42)
2024εΉ΄09ζ22ζ₯ 10:30:17 - INFO: Updated subdomain.example.com: 203.0.113.1 -> 203.0.113.42
{"timestamp":"2024εΉ΄09ζ22ζ₯ 10:30:15","level":"INFO","message":"Current public IP: 203.0.113.42"}
{"timestamp":"2024εΉ΄09ζ22ζ₯ 10:30:17","level":"INFO","message":"Updated subdomain.example.com: 203.0.113.1 -> 203.0.113.42"}- No hardcoded credentials - Uses AWS CLI credential chain
- Input validation - All inputs are validated and sanitized
- Secure temporary files - Uses
mktempwith proper permissions - Minimal AWS permissions - Only requires Route 53 access
- IP format validation - Ensures valid IPv4 addresses
- Safe error handling - No sensitive data in error messages
Run the test suite:
# Run tests
./tests/test_basic.sh-
"Could not determine public IP"
- Check internet connectivity
- Try manual IP detection:
curl -s http://checkip.amazonaws.com - Configure fallback services in
config.env
-
"Invalid JSON in hosts.json"
- Validate JSON syntax:
jq . hosts.json - Check for trailing commas or syntax errors
- Validate JSON syntax:
-
AWS Permission Errors
- Verify AWS CLI:
aws sts get-caller-identity - Check Route 53 permissions
- Ensure correct zone IDs in
hosts.json
- Verify AWS CLI:
-
"Missing required dependencies"
- Install missing packages:
sudo apt install curl jq awscli
- Install missing packages:
Enable debug logging:
# In config.env LOG_LEVEL="DEBUG" # Or run directly LOG_LEVEL=DEBUG ./update.sh
Validate your setup without making changes:
# Dry run mode (check config only)
aws route53 list-resource-record-sets --hosted-zone-id YOUR_ZONE_ID- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
./tests/test_basic.sh) - 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.
- π Documentation: Check this README and inline script comments
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
See CHANGELOG.md for a detailed history of changes.
Perfect for: Home labs, small offices, development environments, or any setup requiring reliable dynamic DNS updates with AWS Route 53.
β If this project helps you, please consider giving it a star!