Aunque es un proyecto sencillo, resuelve para mi un problema que tenia en casa: Saber cual es la ip externa de mi conexión y sobre todo, si esta cambia, recibir una notificación con la nueva IP.
Para ello hago uso de la raspberry Pi que tengo en casa con un sencillo script que podéis encontrar en http://ift.tt/1IWxJ0N
Os dejo la explicación completa del script que he escrito para GitHUB.
Get a push notification via PushOver when your computer changes its public IP.
Because I have a Raspbery Pi in my home where I have some tools. I want them to be accesible from the internet. I can’t use ddns, so, I want to be notified when it changes in my phone.
Put all the files on your home directory, in my case it was /home/pi/
. This is going to be yours if you use a raspberry pi like me.
Make the script executable and the file currentIP.txt
accesible with the command:
chmod 777 currentIP.txt script.sh
First of all you have to edit the script file in te repository to match your personal data:
You have to give the script the path to the currentIP.txt file on lines #14 and #35 Note that the user that runs the script must give write access to the file.
Make an account on pushOver and create a new application to hold all the push notifications. You have to write in the script these:
Customize the message that you will reicive with the notification on line #33 changing the string la nueva IP es
for your text.
--form-string "message=la nueva IP es $IP"
Now if you fire it with sh script.sh
it will send you the current IP but we want this to be done by itself when we are not at home so we are going to use crontab.
To make your linux box to check IP changes you can use crontab. crontab -e
You get the file where you cron jobs are listed. Add a new line at the end of the file like this: */30 * * * * sh /home/pi/script.sh
It will run the script.sh
at hour:30 minutes and at o’clock hours: 12:00-12:30-13:00-13:30—–and so on.
If the IP changes you will reicive the notification with the new IP, if not it will wait for another 30 minutes.
If you want to know more about crontab to setup another configuration, please refer to:
I’m @rafarq on twitter. I would appreciate to know about you If you find this script useful for you.