This script is designed to dynamically update a DNS record's IP address with your public IP address on a configured schedule. The script uses the GoDaddyPy library to interact with the GoDaddy API for managing DNS records. It checks for changes in your public IP and updates the DNS record accordingly.
- Automatically updates a specified DNS record with the current public IP address.
- Configurable logging with file rotation.
- Runs at a specified interval using the
schedule
library. - Creates the DNS record if it doesn't exist.
- Uses GoDaddy API for DNS management.
- Python 3.x
schedule
(for task scheduling)pif
(to retrieve the public IP address)godaddypy
(to interact with GoDaddy's DNS API)
The logging configuration is set up with a rotating file handler:
- Log file path:
./log/dns_scheduler.log
- Log rotation: The log file will rotate when it reaches 5MB, keeping up to two backup logs.
Currently, the DNS update check runs every 5 seconds. To change this frequency, modify the schedule.every(5).seconds.do(job)
line in the code.
- DNS not updating: Ensure your GoDaddy API credentials are correct and have permission to modify DNS settings.
- Logs not appearing: Check that the
./log
directory exists and has write permissions.
- Install the required libraries:
pip install schedule pif godaddypy
-
Clone this repository to your local machine.
-
Replace the following placeholder values in the script:
: The domain name you want to manage (e.g., example.com). : The subdomain (e.g., www, api) you want to update. Leave empty if it’s the root domain. PUB_KEY and SEC_KEY: Your GoDaddy API key and secret key, respectively. IP ADDR: Optionally, specify a static IP. The script will retrieve the IP automatically if this is left empty.
- Run the script:
python3 dns_scheduler.py