Skip to content

hamzamerzic/rpi-public-ip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Fetch and forward Raspberry Pi's public IP via email.

The purpose of this tool is developing a daemon for fetching Raspberry Pi's (or any other Linux distro's) public IP and sending it to a desired email address at a desired time step. After you finish setting up this script, you will be informed at a defined timestep, or at every system boot if the IP address of your machine has changed.

This script is useful for creating a webserver, using VNC outside a local network or being able to SSH to a dynamic IP host. Knowing the public IP of a dynamic IP host has numerous other useful uses.

Install

To install the tool, download the public_ip_hander.py file and place it in a suitable folder, e.g. /home/user/. Then edit the fields: to, gmail_user and gmail_password, to match the email of the recipient and email and password of the sender.

After you have successfully edited the script, in order to execute it write in terminal (replace /home/user/ with your path to file):

python /home/user/public_ip_handler.py

Setup

Send IP at a defined timestep

Now, to setup the script to be executed at a desired timestep, we shall use the built-in cron tool.

To open cron editor, write:

crontab -e

If you want to execute the script each day at 12:00, append the fallowing command to the editor:

0 12 * * * python /home/user/public_ip_handler.py

For more crontab options, you can consult the official manual or this quick reference.

Send IP at system boot

To send your Pi's IP at each system boot, you have to edit the hidden ~/.bashrc file. The command to that is:

echo 'python /home/user/public_ip_handler.py' >> ~/.bashrc

Attribution

The public_ip_hander.py is a modification of the startup_mailer.py script under the "Creative Commons Attribution-ShareAlike 3.0 Unported License".

About

Fetching public IP and sending it via email. Useful for creating webserver based on Raspberry Pi.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages