Pekka Helenius 19a0c08bf8 | 4 years ago | |
---|---|---|
arch_linux | 4 years ago | |
images | 6 years ago | |
ssmtp_conf-sample | 4 years ago | |
LICENSE | 6 years ago | |
README.md | 4 years ago | |
wanchecker.service | 5 years ago | |
wanchecker.timer | 5 years ago |
WAN IPv4 checker & email notifier for computer environments behind dynamic IP address.
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.
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
Linux OS
systemd
sSMTP - (SMTP) email client (package: ssmtp
(Arch Linux), ssmtp
(Ubuntu))
curl
bash
awk
cat
grep
sed
wc
Optionally: resolvconf-override (GitHub/hadess)
systemd system service file: wanchecker.service
mail
and group mail
. Change these if necessary.systemd system timer file: wanchecker.timer
WAN IP check interval is customizable in systemd timer file. Default value is 15min
sSMTP sample configuration files
/var/spool/mail/ip_wan.log
is defined in this file. The log file is updated only when WAN IPv4 changes have been detected.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
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.
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:
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
This repository uses GPLv3 license. See LICENSE file for details.