Do you know what really grinds my gears. grinds my gears Having to boot Raspberry Pi with a new image on and no HDTV to configure and find the IP in order to ssh to it, and have fun with it. Grrrrrrrrr...

That's when I decided why not create a script, that when the pi boots up it sends me the internal and external IP addresses...

Clever right.

[sourcecode language="bash"]

copy and paste the following code and don't forget to edit the username, password and address.

[sourcecode language="python"]
import subprocess
import smtplib
import socket
from email.mime.text import MIMEText
import datetime
import urllib2
import time
# Change to your own account information
gmail_user = "***"
gmail_password= "******"
to = "***"
smtpserver = smtplib.SMTP('', 587)
smtpserver.login(gmail_user, gmail_password)
today =

arg='ip route list'
data = p.communicate()
split_data = data[0].split()
ipaddr = split_data[split_data.index('src')+1]
extipaddr = urllib2.urlopen("").read()
my_ip = 'Local address: %s\nExternal address: %s' % (ipaddr, extipaddr)
msg = MIMEText(my_ip)
msg['Subject'] = 'IP For RaspberryPi on %s' % today.strftime('%b %d %Y')
msg['From'] = gmail_user
msg['To'] = to
smtpserver.sendmail(gmail_user, [to], msg.as_string())


Now for this to work you need to link the script to /etc/rc.local this will only run it once on reboot.

[sourcecode language="bash"]
python /home/

# More mods are underway