Dynamic DNS services provide you with a domain name you can use with a non-static IP address, like most home computers have. To use these requires some action to periodically contact the DNS server and let it know if your Dynamic IP address changed. Usually there are complicated scripts provided to do this, and MacOSXHints has published a few.

However one can greatly simplify this with a launchDaemon and a single built in OSX unix command.

First, this assumes that you have set up an account with a Dynamic DNS service. I use the free service provided by FreeDNS. One updates this simply by loading a web page URL. The act of making that page request alerts the DynamicDNS of your IP address and it updates.

Thus all we need is a LaunchDaemon that runs every hour that reloads that page. Here is an example:

You will need to edit the above example an insert the key for your registered dynamic DNS account in the above string GET request. The one above is not for your site. You can find this at FreeDNS by simply manually refreshing your site online and then looking at the URL that it used. Other dynamicDNS services will have other URL structures that you need to query for the update.

A few caveats on getting this to work. First, if you just download that plist file above, depending on how you do this, you may end up with some unwanted extended file attributes. The launch Daemon service won't run files with the wrong permissions or attributes. You can inspect these by listing the file like this:

ls -laeo@ /Library/LaunchDaemons/

if you see any below the file you can then manually delete these with the xattr command. For example, if there is quarantine from the download you can get rid of it like this.

I don't have info on the FreeDNS update policies, but before you install this make sure to check the update policy of your provider. For example, DynDNS specifically considers sending the same info over and over when nothing changes a "bad update" and will block your account if you do it too often.

I had some issues getting this to work on Lion. First, the file was not owned by root:wheel by default, and instead was owned by my username. The permission fix tip yielded an error "No such xattr: com.apple.quarantine"
Instead, this command worked:

Not trying to troll, but itís been years since I last saw a router that did not have support for dynamic DNS built-in. So Iíd first take a look at your routerís config. I would always prefer this. If your router does not support it, then itís a nice hint, of course!

True, but I would think in a lot of cases--if someone is truly running a home server--they are not going to be logged into the server box all the time, and will leave it running at the login screen.

I would +1 your comment if I could though, just for providing a clear and concrete difference between LaunchAgents and LaunchDaemons. I know a lot of folks who get confused over which to choose when rolling their own launchd plists.

While all of this wonderful back-end tweaking is fun I find it a lot easier to use DNS-O-Matic to automatically handle my dynamic DNS updates. It even allows you to update your IP address automatically on opendns.org at the same time as well, so if you are doing any DNS magic with that wonderful service, it will follow you.