An AppleScript to obtain the WAN IP address

Nov 03, '04 08:21:00AM

Contributed by: danva

This my first AppleScript ever so please be kind. If you'd like to get your WAN IP address in order to SSH into your machine from outside, assuming you configured your router to forward SSH traffic (usually port 22) to your Mac, you can use this hint to obtain your WAN IP address:

  1. Copy and paste the script into a new Script Editor document.
  2. Change EMAILADDRESS to an email address of your choosing
  3. Save the script as an application
  4. Invoke it
You'll be presented with an option to email the IP address to the EMAILADRESS address, or to just leave the value in the system pasteboard for later use.

This script can be used as a basis for more tricks if required. For example, make it email the IP by default without presenting the dialog; set up an action in for specific subject to call this script, etc. You get the idea. Just my tiny contribution for the great Mac community.

Comments (21)

Mac OS X Hints