Get email when Public IP address changes using RasberryPi

If you can't spend thousands for a static IP, Try out this script which sends out an email alert whenever Public IP address changes. In a situation where you need a VPN solution without spending thousands on a static IP no matter if you are a HOME user or a Small Business owner, all you need to have is a RasberryPi and a decent Small Business VPN Router. For this article I used a Cisco RV110w VPN Router.

PrerequisitesRasberryPiDecent Small Business VPN Router ( I used CISCO RV110w Small Business VPN Router )

We are gonna use RasberryPi and an automated script running on it to extract the Active Public IP to be used when configuring a VPN client to connect a remote VPN server which would be accessible no matter where you are, you would be able to access your LOCAL home/Office LAN as long as there is Internet availability.

First you need to setup a outgoing email server on your RasberryPi so that it send you email alerts. Check this article for that setup.Next would be to copy this script onto RasPi and create a CRON Job at a given interval for it to poll for public IP and alert you via email whenever Public IP changes.

Line 2: Creates a file to store the value of Public IP in /root/ipaddress.Line 3: Pulls the current Public IP from "checkip.dyndns.org" of your ISP/Internet Provider and stores that in CURRENT IP variable.Line 4: Checks if there is a regular file created in /root/ipaddress.Line 5: Takes the value from IPFILE for comparing it to KNOWN IP.Line 10: Compares the value of CURRENT IP and KNOWN IP and if different, fires up an email alert with the changed IP, otherwise no alert.