Skip to content

jack-mil/ip-notify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sends a Discord webhook notification when your public IP changes

Explanation: I run a number of services behind a NAT at home which are only accessible through a WireGuard VPN. My IP rarely if ever changes, but if it does, this script will send me a Discord notification so I can update my VPN endpoint while away from home.

Yes, obviously this problem is solved with a DDNS service, of which there are many. But, I don't have any public DNS records and only need the IP endpoint for WireGuard.

Can easily be run on a timer with cron or systemd on your host.

Also can run in a Docker container with supercronic on a configurable schedule.

Makes use of Mullvad or Proton ip-lookup service.

Repo has moved to Codeberg, the Github mirror may not be updated indefinitely. See: Give up GitHub

Usage

  • The script ip_notify.py runs as a oneshot service. It caches the current ip to a file and checks for differences on next run
  • Run as a cron job
  • Or run the supplied docker image and/or Compose project (supercronic in Docker)

Args

  • --service The desired service to send the notification to (discord | msteams. Default: discord)
  • --webhook The webhook endpoint (Required)
  • -o | --cache-file The file to write save the previous ip to (Default: $XDG_CACHE_HOME/ip_notify_cache)
  • --test Send the webhook even if the IP hasn't changed

Env Vars

Most useful when running in Docker (See docker-compose.yml).

# The webhook url. Include here or in .env file
WEBHOOK_URL=${WEBHOOK_URL}
# Cron expression used by the container scheduler
SCHEDULE=*/30 * * * *
# The service used to post webhooks to
WEBHOOK_SERVICE=discord
# The color of the Discord Embed in hex
EMBED_COLOR=1bb106
# The link when clicking the Embed author
AUTHOR_URL=https://codeberg.org/jack-mil/ip-notify
# The icon for the Embed and User avatar
ICON_URL=

Service configuration

Discord

  • Select the settings icon of the channel you'd like to receive the webhook in
  • Go to "Integrations"
  • Click "Webhooks"
  • Press the "New Webhook" button
  • A new webhook should appear; select this and press the "Copy Webhook URL" button

Teams

  • Press the meatball menu icon (3 dots, horizontal) next to a Teams channel
  • Select "Workflows"
  • Search for "webhook"
  • Select "Send webhook alerts to a channel"
  • Configure the desired Teams and channel
  • Copy the webhook URL and make sure the workflow is activated

Developing

  • Since this is a simple no-dependency script, host execution can use any local Python 3 install.
  • Dockerfile and an example Docker Compose project are provided if preferred.

Thanks to these projects for inspiration:

License

This source code is available for use under the terms of the MIT License. See LICENSE

© Copyright 2023-2026, jack-mil and contributors.

About

Discord notifier for public IP changes (Mirror of https://codeberg.org/jack-mil/ip-notify)

Topics

Resources

License

Stars

Watchers

Forks

Contributors