If you do not have a fixed IP you may already also be using something like DynDns to access your own Home-Network.
If you are also using Zabbix for Monitoring you may want to include an additional Information Layer to be notfied, when your public IP changes.
Reason? I myself also have had the problem that the DynDns Update failed and i had no information what my new “public IP” was. If Zabbix sends an EMail (it has had new Internet-Access) than you may be able to “recover” and dial in again (VPN…) using the IP and not your Dynamic DNS Name.
Getting public IP
How can you get your public IP?
There are a lot of Services to get it. Just use google.
Eg. ipfy “https://api.ipify.org/?format=plain” will provide it.
You may also use a simple custom solution on your own VServer or Webhosting-Package/Domain like setting up a PHP-Script to send back your IP.
Example (myip.php):
<?php
echo $_SERVER['REMOTE_ADDR'];
?>
Create Zabbix Host
If you have already created a Host (see Zabbix Internet Connectivity Check) you can use it. Or else create it.
Create Item to get public IP
The Web Scenarios do not work for this Use-Case.
But there is a HTTPAgent in Zabbix.
Go to items and Create a new one.
Name: GetPublicIP
Type: “HTTP agent”
Key: public_ip
Type of Information: Character
URL:
Custom: https://my.domain/myip.php
Or a public available Service URL
Update Interval: 5m
Press Add.
Create Trigger
Now go to Triggers and Create a new one.
Name: PublicIPChange {ITEM.VALUE}
Severity: Information
Description: Public IP has Changed {ITEM.VALUE}
Expression:
(last(/Network connectivity checks/public_ip,#1)<>last(/Network connectivity checks/public_ip,#2))>0
Press Add and that’s it. Now if you want to test it just disconnect and reconnect to the internet and Zabbix will send an Notification that your IP changed. (Also 5min later it will also be automatically resolved).