This program checks for when your public ip address changes, and uses gmail to notify any number of people with useful information. This program works best when setup with a cron job.
You can force an email to be sent regardless of if the ip has changed by using the -f
or --force
options.
./ip_watcher.py --force
Written for Python 3.6.5
pip install requirements.txt
Generate an app password for your account here
Create a file named settings.yaml in this directory and populate it using this template:
from_email: <your gmail username>
gmail_username: <your gmail username>
gmail_password: <your app's password>
to_emails:
- <recipient's email>
- <recipient's email>
email_template_filename: change_email.txt
email_subject: <notification email's subject>
dns_name: <your DNS name>
dns_management_link: <URL to wherever you manage your DNS>
previous_ip_filename: .previous_pub_ip
Create a file in this directory with the same name for email_template_filename
that you specified in settings.yaml.
The program expects you to have the template setup for string formatting. Values are filled in with a specific order:
- domain name
- previous public IP
- current public IP
- DNS management link
Your Public IP Address Has Changed For Your Domain %s.
Previous IP address: %s
Current IP address: %s
Manage your DNS resolution here: %s
---
Message generated by the public_ip_watcher program