I am a big fan of music, and I like to listen to all my music wherever I am and whatever I do (specially when coding).

All my medias are stored on a NAS drive that features a little embedded linux distribution as operating system. One of the service is called iTunes media sharing (mt-daapd is the real name of the daemon).

It is really a cool feature as I can listen media stored on my NAS from whatever device on my LAN. The magic behind is called Bonjour which is a protocol that allows device to register themselves on the network and being discovered by others.

My problem is I want to be able to listen to my home music at work, and Bonjour service does not go out of my LAN. The additional thing is I want to listen to my music using iTunes (I am fond of Bowtie) on my MacBook Pro.

Simulating Bonjour presence

The trick is to use a little software called dns-sd to register your distant IP-address as a Bonjour source, by executing the following command (replacing YOURIP with your public IP), you should see a shared library (named MYNAME) in iTunes :

dns-sd -P MYNAME _daap._tcp. "my details" 3689 homemusic.local YOURIP&

If it does not work, I think you've forgotten to open the 3689 TCP port of your firewall and / or to forward it to your box running mt-daapd.

Modifying iTunes to launch dns-sd

The thing is that it is not very convenient to launch the command line with iTunes, it would be better if all was automatic.

There is a simple way of doing it that you'll have to do each times iTunes is updated, moving the actual iTunes binary to another file and trigger its launch from a small shell script.

First step is to move iTunes binary, launch a Terminal.app and type the following :

mv /Applications/iTunes.app/Contents/MacOS/iTunes /Applications/iTunes.app/Contents/MacOS/iTunes.bin

Then, create the following shell script and record it under /Applications/iTunes.app/Contents/MacOS/iTunes

dns-sd -P MYNAME _daap._tcp. "my details" 3689 homemusic.local YOURIP &

Finally, make the script executable by chmodding it :

chmod +x /Applications/iTunes.app/Contents/MacOS/iTunes

The next time you'll launch iTunes, the dns-sd service will be automatically launched, your shared media library will appear and your ears will love this !

WARNING : you actually expose your media library to everyone on the internet, I suggest you to set a password / change port number / use a SSH tunnel to circumvent this...

comments powered by Disqus