A Python script that updates your dynamic DNS IP address with DNS-O-Matic. The script uses ifconfig.me to get the current public IP address and compares it with the last stored IP. If the IP address has changed, the script updates the DNS information on DNS-O-Matic.
- Fetches current IP address using
ifconfig.me
. - Stores credentials in a local configuration file (
pyomatic.cfg
). - Compares stored IP address with the current IP.
- Updates DNS-O-Matic if the IP address changes.
- Provides detailed messages for DNS-O-Matic responses.
-
Initial Setup:
- Prompts for your DNS-O-Matic credentials (
user_email
,password
) andhostname
. - Stores them in a plain text configuration file.
- Prompts for your DNS-O-Matic credentials (
-
Fetching Current IP Address:
- Fetches the current public IP address using
ifconfig.me
.
- Fetches the current public IP address using
-
Comparing and Updating:
- If the current IP address differs from the stored IP, it sends an update to DNS-O-Matic.
- Handles and interprets DNS-O-Matic response codes.
- Python 3.6 or later
requests
library
Install the required package by running:
pip install requests
Configuration is handled through a local file, pyomatic.cfg. The script will prompt you for credentials if any are missing.
Below is an example configuration file after the script has run once:
[Settings]
current_ip = 123.123.123.123
user_email = yourname@example.com
user_pw = yourpassword
hostname = yourhostname.com
Note: The credentials are stored in plain text.
The following table explains the various response codes returned by DNS-O-Matic:
The following table explains the various response codes returned by DNS-O-Matic:
Code | Meaning |
---|---|
good |
The update was accepted and will be distributed to all linked services. |
nochg |
The update succeeded, with no change. DNS-O-Matic will not re-distribute successive ''nochg'' updates. |
badauth |
The DNS-O-Matic username or password specified are incorrect. |
notfqdn |
The hostname specified is not a fully-qualified domain name. |
nohost |
The hostname passed could not be matched to any services configured. |
numhost |
You may update up to 20 hosts. numhost is returned if you try to update more than 20 or update a round-robin. |
abuse |
You are sending updates too frequently and have been temporarily blocked. |
badagent |
The user-agent is blocked. |
dnserr |
DNS error encountered. Stop updating for 30 minutes. |
911 |
There is a problem or scheduled maintenance on DNS-O-Matic. Stop updating for 30 minutes. |
More details are available at the DNS-O-Matic API Documentation.
- Clone or download this repository.
- Ensure you have Python 3 and
requests
installed. - Make sure
pyomatic.py
is executable by running:
chmod +x pyomatic.py
- Run the script:
python pyomatic.py
Run autoupdate.py
to set up the time-based job:
python autoupdate.py
For Unix-like systems, a cron job is created. For Windows, a Scheduled Task is created.
Enter your user email: yourname@example.com
Enter your password: yourpassword
Enter your hostname: yourhostname.com
DNS-o-Matic update response: The update was accepted and will be distributed to all linked services. (IP: 123.123.123.123)
This project is licensed under the MIT License.
If you encounter errors like Exception has occurred: ValueError
, ensure your Python environment has all necessary packages and the correct interpreter is being used.