Sunday, August 5, 2012

Sharing iTunes Library over VPN

I have a very nice music library on my home Mac (iTunes). I share this library so when I'm at home, I can play music from the library from my laptop, mobile devices or even AppleTV. However, when I'm at work, the library is not visible, even though I have a VPN connection to my home (the server where iTunes is running is accessible).

I will not go through on how to set up a VPN connection to your home - as it highly depends on your router at home and other factors. If your router does not support VPN, SSH tunneling is probably your best bet. In this case, some of the instructions below may slightly defer.

As my server is already sharing my library at home, there is nothing I need to do on the server.

Windows


Generally, all you need is Bonjour-Beacon. Download the zip file, extract it somewhere and then launch BonjourBeacon.jar from the extracted directory. This tool publishes ZeroConf (aka Bonjour) services that the computer it is running on provides. In this case we want to publish that your computer provides iTunes Library Sharing service (daap). This service runs on TCP port 3689. Bonjour-Beacon doesn't of course provides this service but what it does is that whenever someone tries to access the service it publishes, it will forward the connection (kind of like proxy) to a different server that does provide the real service. In our case that will be the IP of the computer where the iTunes library is shared.



Here's an example of how to configure Bonjour-Beacon to redirect iTunes library sharing to another computer:

Profile Name:  type any text to describe your library
Host Name:     localhost
               NOTE:  From my experience, this has no meaning
                      except that it will show on your local
                      iTunes before you actually access the
                      remote library
Host MAC:      leave empty
Host IP:       type in the IP of the computer that has the
               library you want to share
Password:      false
Local OS:      Choose your OS (from my experience, you can choose
               anything here)
Protocol/Port: _daap._tcp./3689

The most important settings are Host IP and Protocol/Port. These essentially publish the service on your local network and tells Bonjour Beacon where to forward connections to the published service.

Once done, click the 'Add New' button to add the service. This will add the service but will not publish it just yet. To publish, click the 'Start' button:

That's it. Launch iTunes and you should see the library on the left pane under SHARED. Click it, and your remote library will load (time will depend on your library size and connection speed on both sides of the VPN tunnel).


Mac

Similar to Windows, you'll need software to proxy Bonjour from your local network over to your iTunes server accessible through VPN. For Mac, you'll need Network Beacon. The download button did not work for me. To download, click the 'Home' link on the left and then you'll have a direct download link on the right. Currently, this points to this link.

Once downloaded, open the .dmg files and launch Network Beacon.app. You may want to copy it to your Applications folder for future use.



The configuration is similar to Windows:
Service Name:   Text to describe the service being published (you
                can write any text)
Service Type:   _daap._tcp.
Port Number:    3689
Text Record:    leave empty
Host Name:      the host name of the computer that is sharing the
                iTunes library
IP Address:     the IP address of the computer that is sharing
                the iTunes library

Make sure both "Beacon Enabled" and "Enable Host Proxy" are checked.


Happy playing.


[29/Nov/2012 Update]

Troubleshooting iTunes Library Sharing

My Library sharing, either on LAN or VPN as described above, stopped working on one of my Windows 7 machines. It did work and then it stopped. I tried may things, including:

  • Disabling the firewall
  • Rebooting the Sharing machine and my Windows machine
  • Making sure Home sharing is enabled (not important but still)
  • Verifying both are running the same version of iTunes
  • Different launch sequences
  • Many combinations of the above
I believe, today after leaving the problem as it is for a while now, I found the root cause of the problem. My network connection is configured as a Home network as it should be (I'm at home...). However, I had recently refreshed my VMware Workstation to the latest version. It added a few network adapters (VMnet1 and VMnet8), used for host only and NAT between VMs (guests) and the host (my native Windows 7). Although no VM was running, those interfaces are enabled.

I noticed that in Control Panel -> Network and Internet -> Network and Sharing Center my PC is connected to the internet via "Multiple Networks" (map at the top of the page). I disabled the two virtual interfaces (one way of doing this is clicking 'Change adapter settings' on the left pane and then right clicking an interface and choosing 'Disable'). The map at the top of the page now correctly showed that I'm connected to the internet via a Home network. I quit iTunes and re-launched it and voila! Home Sharing now shows my shared library.