I'm looking for a way to have a client's machine phone home periodically so that I can easily do a ssh login if necessary. I was thinking a simple script that grabs the public IP address and posts it somewhere - Twitter for example, or maybe an http request to an apache server I operate, or an email every time it changes.Are there existing tools / scripts for this purpose? I've searched and haven't found any
How can I find my client's linux box on the internet automatically?
networking;scripting;dns;ip;internet
ddclientThe easiest way is to use ddclient. I use this on my server, combined with a free domain name server, like dynu.com.There is more documentation in the link, but ddclient polls your client's dynamic IP address. When it changes, it sends the new address to dynu.com (for example). You will have an account at dynu.com, where you specify your custom domain name. Then, you can directly connect to http://yourname.dynu.com, which redirects to your client's IP.The advantage over using a numerical IP address is that you don't need to constantly update your ssh config, and can just connect directly to the domain name instead. This works very well on my server.Numerical IPAlternatively, if you don't want to use this, and prefer to post the numerical IP somewhere instead, here is the old script that I used to use. It uses an external webpage to find your local IP, which is the only easy way to do it. It then mails bar@email.com, but you can modify this to suit your needs. You can run this as a cron job.#!/usr/bin/env bashCURRENTIP=$(curl -s http://myip.dnsomatic.com)# Alternatively, use http://icanhazip.comif echo $CURRENTIP | grep -qE '^([0-9]{1,3}\.){3}[0-9]{1,3}$' ; then  if ! cmp --quiet <(echo $CURRENTIP) /home/pi/.myipaddress ; then    echo IP address changed to ${CURRENTIP}    echo $CURRENTIP > /home/foo/.myipaddress    echo -e Foo's IP address has changed to ${CURRENTIP} .\n | mail -s 'Change of IP address' bar@email.com  fi  else    echo ERROR: IP address enquiry returns ${CURRENTIP}fi