iTunes Shared Music - Finding Machine

By: Richard Glaser - Revised: 2006-07-03 devin

Introduction

iTunes has the ability to share music over a local network using zero configuration (aka Bonjour). Sometimes for legal or other reasons, you might want to track down a machine that is sharing music over the network. For example, you could use a utility, to download the users iTunes Shared Music to your local machine, and if the music doesn't implement digital rights managment (i.e. DRM) you have  a free/open copy of the music.


Enable Look for Shared Music

The first step is to enable "Look for shared music" in iTunes. Open up the "Preferences..." dialog box.

iTunes -> Preferences

Next, click on the "Sharing" pane, and make sure "Look for shared music" is enabled.

iTunes -> Preferences -> Sharing

Then connect to the iTunes Shared Music that you would like to track down...

iTunes -> Shared Music Source

Command Line - lsof & arp

After connecting the the shared music with iTunes, enter the following commands...

lsof -c iTunes -a -i

Using the "lsof", list open files, you can get info about the open files used by process like iTunes. The "-c" option lists files processes using iTunes and the "-i" option selects all internet and network files.

Then look for a server socket - the number after the colon is your iTunes server port number.

Then look for outbound client sockets - these look like:

your.host.name: 51090->remote.host.name:daap  (ESTABLISHED)

Where the number after the colon after your name (the port number for your endpoint of the socket) is NOT your iTunes server port number; there may be a number of such sockets, but there will be only one remote host address to which you have two connections - that's the machine you're connect to its shared music.

Is the address enough to figure out whose machine it is? If not, you need to map the IP address to an AppleTalk machine name...

arp -a | grep remote.host.name

The "arp", address resolution display and control, this command displays the internet-to-ethernet address translation tables. This will get you the ethernet address, if you're on the same subnet as the remote machine sharing music.

GUI - Sloth & Network Utility

Also, you can use the GUI tool Sloth, which is a front-end lsof to track down the remote machine sharing music. Sloth is front-end for "lsof" and supports some of its options, but since it is GUI it is a good alternative for those not familar or comfortable with the command line.

Sloth is freeware and can be downloaded at www.sveinbjorn.org/sloth.

Once you have sloth download, launch it, and select the option "Show IP Sockets", enter "iTunes" into the filter text box, and click the "Refresh" button. And you will get output similar to this...

Sloth - Show IP Sockets

As with the command line documentation, you want to look for outbound client sockets, that look something like...

your.host.name: 51090->remote.host.name:daap  (ESTABLISHED)

And use Network Utility, if you can get a hostname...

Network Utility -> Lookup

Or use the "arp" command as noted above.