Skip to content

Detect changes of public ip address and notify via email

Notifications You must be signed in to change notification settings

jkufro/public_ip_watcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Public IP Watcher

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

Prerequisites

Language

Written for Python 3.6.5

Packages

pip install requirements.txt

Gmail Account

Generate an app password for your account here

Create Settings File

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 Email Template

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

About

Detect changes of public ip address and notify via email

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages