- My DSL connection has a dynamic IP address
- My Mac is connected to a router, which gives me a local IP address.
- I'm too cheap to buy a domain-name or register for a Dynamic DNS service.
While the "ifconfig -a" command works great for the local IP address, it doesn't give me the router's IP address to the outside world. However, there is a web-site that provides this service (which I found in a comment at MacOSX Hints). Going to http://checkip.dyndns.org gives you the WAN IP address. The "curl" command allows us to save this page to a file.
Next, we need a convenient place to post this file so you can look-up the current IP address to your computer. The Sites folder in your iDisk will work perfectly. You'll be able to look-up your IP address with a web-browser.
Finally, we need a way to have this file updated on a regular basis. We'll use the "cron" program that was explained a while ago on this site.
Okay, create the following file anywhere in your Home folder:
# $NetBSD: crontab,v 1.13 1997/10/26 13:36:31 lukem Exp $Those are TABS, not spaces. Replace "iDisk_name" with whatever your iDisk is called when mounted. Replace "myip1234.html" with whatever you wish to call the file. If you don't wish to have your IP address advertised, I reccomend you give it a cryptic name--and don't post the link on your web-page ;-). This is set to update the file at the top of every hour. If you like, you can make it update every 30 minutes by replacing "0" with "*/30". Save the file as "mycrontab" or something similar.
#
# ~/Unix/crontab - my crontab
#
SHELL=/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
HOME=/var/log
#min hour mday month wday command
0 * * * * curl http://checkip.dyndns.org>/Volumes/iDisk_name/Sites/myip1234.html
Now, mount your iDisk. Open the terminal and cd to the folder where your "mycrontab" file is stored. Type this command:
crontab mycrontabThat's it! From here on you can view the IP address of your remote machine by browsing to http://homepage.mac.com/iDisk_name/myip1234.html or whatever you named the .html file.
Make sure to enable login and FTP through the File-Sharing preferences. I HIGHLY reccomend you use ssh and sftp to connect for security. If you are given a local IP address from a router, your next task will be to forward the telnet and FTP ports from the router to your machine. As this varies with different routers, I'll let you read the directions.
[Editor's note: First, I have not tried this myself, but it seems straightforward. Second, the tip depends on having your iDisk mounted at all times, so you'll have to use the WebDAV method (which has no timeout). Alternatives that come to mind including writing the info to a file and then using an automated FTP client to move it to a web site; mailing it to yourself; etc. Finally, this tip demonstrates an effective use of 'cron' -- cool stuff!]

