A RouterOS script that monitors the external IP address by querying ipify.org.
If the IP changes, it sends an email notification with the new and previous IP addresses.
This script is useful for:
- Monitoring public IP changes in dynamic IP environments.
- Triggering alerts for DDNS updates or remote access awareness.
- RouterOS with internet access and DNS resolution.
- RouterOS with configured mail sending (SMTP).
- The supporting function script SendEmailFunction must be imported and configured.
- Script access policies:
read,write,policy,test.
- Fetches the current public IP from
http://api.ipify.org. - Compares it with the previously stored IP (
global CurrentIP). - If changed — updates the variable and sends an email notification.
/import file-name=Script_CheckChangeExternalAddress.rscor copy the script contents into a new script via Winbox/WebFig.
Edit this line in the script:
:local SendTo "YOUR_NAME@DOMAIN.com";
Run the script periodically to detect changes. Use the scheduler provided in the file Schedule_CheckChangeExternalAddress.rsc or create manually:
/system scheduler add name=CheckChangeExternalAddress interval=5m on-event="/system script run CheckChangeExternalAddress;" comment="Check Change External IP address and notify" policy=read,write,policy,test start-time=startupSubject: Mikrotik INFO: MyRouter [2025-07-14 11:32:00] External IP address has changed.
IP Address Change Notification
Device: MyRouterName
Date: 2025-07-14
Time: 11:32:00
New IP Address: 203.0.113.47
Previous IP Address: 203.0.113.14
This is an automated message.
- Make sure your firewall allows outbound HTTP (TCP 80) for API request to
http://api.ipify.org. - SMTP must be correctly configured in /tool e-mail.
- Use logs to trace issues:
/log print where message~"CheckChangeExternalAddress"- You can run the script manually:
/system script run CheckChangeExternalAddress- Limit access to the script and scheduler by assigning proper user rights and policies.
- Use a dedicated and secure mailbox for receiving notifications.
If you have questions, suggestions or bugs, create an issue in the repository: GitHub Profile
Author: Hackitect7
Date: 2025