WAN IPv4 checker & email notifier for computers behind dynamic IP/DHCP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Pekka Helenius 759011ba62 Update Systemd files: remove network requirement, reduce timer interval, other minor changes 4 years ago
arch_linux Add Arch Linux resolvconf-override build script 4 years ago
images Initial commit 6 years ago
ssmtp_conf-sample Add wanchecker.conf 4 years ago
LICENSE Add LICENSE 6 years ago
README.md Update README 4 years ago
wanchecker.service Update Systemd files: remove network requirement, reduce timer interval, other minor changes 4 years ago
wanchecker.timer Update Systemd files: remove network requirement, reduce timer interval, other minor changes 4 years ago

README.md

WAN IP checker

WAN IPv4 checker & email notifier for computer environments behind dynamic IP address.

About

In many home networks, WAN (Wide Area Network) IP addresses are dynamically allocated by a local ISP. Usually this is acceptable in common household/home use, but not in server use where static DHCP lease/static IP address is very much a mandatory requirement.

If configuring a static WAN IP is not an option to you, consider setting up a simple notifier which let's you know when your WAN IP address changes.

Static IPs are usually offered only to corporate environments, and not everyone wants to pay extra for such in order to establish a simple server environment in home.

This repository contains a Systemd service & a simple bash script to refresh current WAN IPv4 of a Linux computer, and notify administration for any changes in the WAN IPv4 (Internet) address. This method addresses to several issues:

  • Administreation is always aware of the current server IPv4 address, whether the address is dynamic or not.

  • Administration is able to remotely connect to the server environment although the server IP has been changed. This is possible because admins are notified about any WAN IPv4 address changes via email by the server itself, automatically.

Failure countermeasures

The WAN IP checker script has several countermeasures for the following failures:

  • DNS name resolution fails: DNS servers defined in /etc/resolv.conf can not be contacted

  • Sending email fails

    • Attempt several times until informing that sending an email message has failed

Requirements

Contents

Manual installation & configuration

1) Install ssmtp package

2) Deploy provided files as follows:

Repository location Filesystem location
ssmtp_conf-sample/wanchecker.sh /etc/ssmtp/wanchecker.sh
ssmtp_conf-sample/wanchecker.conf /etc/ssmtp/wanchecker.conf
wanchecker.service /etc/systemd/system/wanchecker.service
wanchecker.timer /etc/systemd/system/wanchecker.service
File Owner (u.g) Permission bits
/etc/ssmtp/wanchecker.sh root.mail 0750
/etc/ssmtp/wanchecker.conf root.mail 0640
/etc/systemd/system/wanchecker.service root.root 0644
/etc/systemd/system/wanchecker.service root.root 0644

3) Configure sSMTP files /etc/ssmtp/revaliases (sample), /etc/ssmtp/ssmtp.conf (sample). More information about these files on sSMTP Arch Wiki site.

4) Configure file /etc/ssmtp/wanchecker.conf (sample)

5) If necessary, configure sSMTP as described in sSMTP Readme file.

6) Run (as root or with sudo):

systemctl enable wanchecker.timer && \
systemctl start wanchecker.timer

7) (optional) Install resolvconf-override

Arch Linux installation & configuration

1) Use provided PKGBUILD file

2) Configure files /etc/ssmtp/revaliases (sample) and /etc/ssmtp/ssmtp.conf (sample). More information about these files on sSMTP Arch Wiki site.

3) Configure file /etc/ssmtp/wanchecker.conf (sample)

4) Run (as root or with sudo):

systemctl enable wanchecker.timer && \
systemctl start wanchecker.timer

5) (optional) Install resolvconf-override. Use provided Arch Linux PKGBUILD file.


Images

When server computer discovers a change in its WAN IPv4, it automatically sends an email notification to system administrator(s):

Additionally, server computer keeps a log file which include WAN IPv4 changes and corresponding timestamps:

Useful commands

  • systemctl --all list-timers = list all system timers on Linux system, including wanchecker timer

  • systemctl is-active wanchecker.timer = tells whether wanchecker timer is running or not

  • systemctl status wanchecker.timer = more compherensive output about the status of wanchecker timer

License

This repository uses GPLv3 license. See LICENSE file for details.