Finding Out Your Home IP Address Without DDNS

Sometimes I have a need to SSH into my machine at home from other places. I have no-ip DDNS set up but it’s quite flakey on a Mac and isn’t always up to date! You may also want to do this without setting up DDNS at all or may have forgotten to run the client.

Here is a simple idea that will get around the problem, all you need to do is have your Mail application running! There is no reason why this couldn’t be done on Windows either.

Mail Setup

Create a rule in your Mail application which matches any e-mails with the following conditions:

  • subject line is getip
  • content is not ip response

then set the actions to:

  • reply with text “ip response”
  • mark read
  • delete

It’s important to match the reply content otherwise it will create an infinite reply loop!

Using the System

All you need to do is simply e-mail yourself from any webmail such as GMail or your work e-mail with the subject line ‘getip’ and extract the IP address from the headers in the reply.

As a test I have e-mailed myself from GMail, and then in GMail chosen ‘show original’ from the drop down menu which will give the raw e-mail.

The raw e-mail format will vary a bit depending on the sending client but typically the furthest down ‘received’ section will have the external IP address in (higher ones are from when it passes through various e-mail servers):

Received: from 5f05f615.bb.sky.com ([94.4.246.21] helo=[192.168.0.6]) by mail5.atlas.pipex.net with esmtpa (Exim 4.71) (envelope-from <foo@bar.com>) id 1PoEMq-0005T2-Bq for foo@bar.com; Sat, 12 Feb 2011 12:14:24 +0000 </foo@bar.com>

You can see in red the external IP address that we’re after just before the local machine IP which is a good clue that that’s the right IP you’re looking for.

As a proof of concept this matches the external IP address as currently displayed on the router, as you would expect:

ADSL Port

MAC Address     00:25:b3:f8:7e:79
IP Address      94.4.246.21
Network Type    PPPoA
IP Subnet Mask  255.255.255.255