How to report a changed external IP

Endorsed by Nick The Ninja

We have the issue that the external IP for the SMA is not static.
All few weeks the provider changes the external IP so the access is not granted until the DNS is modified. 
Due to a few issues this is not possible via an API and needs to be made manually. 
Especially if on tour this may be a big problem.

In our case one of the internal servers (Linux) runs a little script which reports the changes via email.

A SMTP server is setup that an email can be sent. Set this up so it does not send cron-emails because this could fill the mailbox.


# check and send ip address to email
MYIP=$(curl ifconfig.me);
if [[ ${MYIP} != ${LASTIP} ]]
        echo "New IP = ${MYIP}"
        echo "sending email.."
        echo -e "Hello\n\nAt Timestamp = ${TIME} the IP was changed to\nIP = ${MYIP}\n\nThanks, Admin" | \
                /usr/bin/mail -s "[IP Change notification]" ADMIN-EMAIL;
        echo ${MYIP} > ${LASTIPFILE};
        echo "no IP change!"
fiThe script should be obvious, it checks the current external IP by surfing to https://ifconfig.me which simply returns the external IP.
If this differs to the old saved one it will send an email with all important info to the ADMIN-EMAIL (add here your own)

Now you can test it and if it works as suspected, you can simply automate it via cron to run all 5 minutes (in that example) and don't send any emails from it.
*/5 * * * * /SCRIPTLOCATION/address.sh >/dev/null 2>&1This script can be run under any user account, root is not suggested


This post is locked
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ