During the spring of this year, I switched my old, trusty XMBC-powered Ubuntu machine to a Mac Mini, using Plex, for my mediacenter use.
Eventhough maintaining a Mini requires a lot less fiddling than the Ubuntu machine (Which is the reason why I bought it in the first place), I wanted to be able to access it from outside my home network (For queueing videos when not at home for instance).
Now, there are a few different ways to handle dynamic DNS, but my favourite is currently FreeDNS, as it's free, and it doesn't require any software installed on the machine your want DNS for.
Registering for dynamic DNS
So, the way FreeDNS works, is that you sign up at http://freedns.afraid.org/, and register for a domain name.
When you're signed up, they have a cURL script available, and some simple ways of letting your machine tell FreeDNS it's actual, current IP, which allows FreeDNS to point the domain to the right IP.
Getting the Mac to send the public IP to FreeDNS
For the Mac they also have a LaunchAgent plist ( Available in the list on http://freedns.afraid.org/scripts/freedns.clients.php ), which allows for setting up a Mac to run an update, once your system configuration changes, like when you get a new IP.
Here's a version of the plist without comments ( Watch the whole thing on http://freedns.afraid.org/scripts/org.afraid.freedns.plist.txt )
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/ PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.afraid.freedns</string> <key>Program</key> <string>/usr/bin/curl</string> <key>ProgramArguments</key> <array> <string>curl</string> <string>-s</string> <string>http://freedns.afraid.org/dynamic/update.php?secretkey</string> </array> <key>WatchPaths</key> <array> <string>/Library/Preferences/SystemConfiguration</string> </array> </dict> </plist>
As you may notice, what this does, is to things:
- It watches '/Library/Preferences/SystemConfiguration' for changes
- It triggers curl silently, calling the FreeDNS updater.
How does it work ?
This requires two things you need to do, to make it work:
You need to change the URL in the .plist "http://freedns.afraid.org/dynamic/update.php?secretkey" to correspond to the one found as "Direct URL" on http://freedns.afraid.org/dynamic/
Save the .plist in <Startup Disk>/Library/LaunchAgent
Let me know if you encounter any issues, and I'll revise my post ;)