USB NAS and print server

I assume you have a compatible router with usb ports with the Teddy Bear mod Tomato firmware installed.

These instructions show that the USB NAS portion is quite easy. Once the hard drives are connected, they are automatically mounted in the router’s Linux OS. A computer on the same network can connect to the router’s hostname/ip via the samba protocol or ftp (if enabled).

Printserver was less obvious since I wasn’t familiar with it. Tomato uses p910nd printer daemon. By default, only 1 instance is running on Tomato on port 9100. If you plan on connecting multiple printers (eg, adding through a USB hub), then you will need to run additional instances of p910nd in the startup script of the Tomato firmware:

 <pre class="src src-sh">/usr/sbin/p910nd -b -f /dev/usb/lp1 1

Continue to add 2, 3, …, if more printers are required. Reboot the router, and another instance is added to port 9101, etc. Note: the ordering is based on the proximity of the USB ports. Check the USB page on the router config site to determine the ordering.

To add a printer on a Windows machine, you will have to add it MANUALLY (auto-detect of any kind will not work). Following copied in case those links die:

HOW TO SET UP A PRINTER WITH TOMATO

  • I installed the printer the same exact way I do most USB print servers
  • GO TO ADD PRINTER
  • ADD A NETWORK PRINTER
  • SKIP AUTO DETECTION AND DO IT MANUALLY
  • ADD A PRINTER USING A TCP/IP ADDRESS…
  • DEVICE TYPE: TCP/IP DEVICE
  • HOSTNAME/IP: Your_Router_IP (ex: 192.168.1.1, mine is different), PORT NAME: let it auto-populate
  • UNCHECK the “Query the printer…”
  • Detection should fail…
  • On bottom, DEVICE TYPE click on CUSTOM, then SETTINGS
  • Leave all default ports and settings and click OKAY
  • Finish everything and print a test page.

On my Ubuntu, searching the printer on the router’s hostname/ip works. However, on all machines, you will have to select the type of printer manually.

UPnP Media Server for PS3 and others: MediaTomb

I wanted to get XBMC on my brother’s PS3, but since he has a PS3 slim, the “otherOS” feature was not available. However, Sony’s got to allow streaming to it right? Yep, via the UPnP (Universal Plug and Play) protocol.

I used this guide to set up MediaTomb. On Ubuntu, basically,

 <pre class="src src-sh">sudo apt-get install mediatomb mediatomb-daemon

## don’t do sudo mediatomb since I will be utilizing daemon sudo emacs -q -nw /etc/mediatomb/config.xml ## change to yes ## uncomment or add this line ## Next, go to http://server.ip:49155/ and add the location of the media

My PS3 didn’t see mediatomb. After debugging with the help of the author over at #mediatomb over on freenode, I found out that the wireless bridge the PS3 was plugged to did not pass over all udp unicasts. There were communications between the two but the connection was not established because there were missing pieces.

In the process of debug, I used cidero and wireshark and tshark (via apt-get) per the faq. Basically, using cidero with my laptop plugged into the wireless bridge, I could see mediatomb. Using the web browser on the PS3 I could get to the mediatomb web ui. Plugging the PS3 onto the primary router, I see mediatomb. Then I used tshark to capture the connection information when the ps3 is searching for a media server and sent the capture to the author and he couldn’t help me any further since it was the setup’s fault. Haven’t found a way around this wireless bridge yet, although I posted in the DD-WRT forum.

Stream music to client via DAAP

Now that I have a NAS at home, I plan to place stuff that takes up a lot of space that doesn’t get used so often on there. However, with that comes the issue of file access. Since my NAS is linux based – ubuntu server edition to be exact – I can access files via ssh, sftp, ftp, sshfs (map the drive), samba, etc. I should probably write a blog post about sshfs and samba soon.

However, what if I want to listen to music in my music player, say itunes on Mac/Windows or rhythmbox (or amarok, bashee, etc) on Linux? The good thing about itunes and these bloated music players are that they have a database of all your music files, so finding the song is fairly quick (type in artist name or song title). Double clicking the files on the mounted drive is no problem, but having this “search and play” capabilities is quite useful. Luckily, there are many solutions to this, one of which is the DAAP method. Read here for an overview.

Game plan is as follow:

  1. Set up music server on NAS.
  2. Be able to access the songs in itunes or the likes on remote servers in the same network.
  3. Be able to access the songs in itunes or the likes on remote servers when on a different network, say at school (or at work).

The first point is fairly easy on Ubuntu: install Firefly Music Server (formerly known as mt-daapd). Following these instructions, I did

 <pre class="src src-sh">sudo apt-get install mt-daapd

sudo apt-get install libid3tag0 sudo apt-get install avahi-utils ## needed for remote access sudo adduser media su media mkdir /home/media/music exit

Place music in /home/media/music or create a symlink to the music folder.

 <pre class="src src-sh">sudo /etc/init.d/mt-daapd start

sudo update-rc.d mt-daapd defaults

Now, from that computer, go to http://ip.address:3689 (username and password is mt-daapd). On this site, we can set up the configuration. Set username/password, password to listen, and music folder. Then scan the files. (Might have to do sudo /etc/init.d/mt-daapd start).

From here, computers on the network should be able to see the music server in itunes or rhythmbox (point 2) and play music (after entering music password). NOTE: I initially thought that you had to “Open Audio Stream…” or the likes on the music players, but that is for internet radio or something; DAAP servers will broadcast the music server to the network.

To do point 3, the first thing to do is set up port forwarding on the router (3689 to 3689 on the music server). The remaining part is a bit tricky. First, you have to do ssh tunneling so that the remote music server appears to be on the same network as your computer/laptop. Then we have to forward the “broadcast” from the DAAP server (the server that itunes sees, for example).

For a Linux client, instructions can be found here and here:

 <pre class="src src-sh">ssh my@daap.server.no-ip.org -N -f -L local.ip:6689:localhost:3689

avahi-publish-address -v -H “name of your host”.local -s “My daap share” _daap._tcp. 6689 & ## find name of host from echo $HOSTNAME

Now, itunes or other clients on the remote server should see “My daap share” on the Shared list. NOTE: currently, Linux players such as rhythmbox and banshee can’t play music this way. I’m sure a fix should be coming soon. If a mac is also on the same network as this current linux client, it will see the shared daap server and connect and play music.

For a Mac client, instructions can be found here:

 <pre class="src src-sh">dns-sd -P <span style="color: #ffa07a;">"Home iTunes"</span> _daap._tcp local 3689 localhost 127.0.0.1 <span style="color: #ffa07a;">"Arbitrary text record"</span> &amp;

ssh -C -N -f -L 3689:localhost:3689 myusername@blahblahblah.dyndns.org

Itunes should be able to see the remote daap server.

For a Windows machine, I’m sure one would have to rely on RendezvousProxy, following these instructions. I will test this out soon (setting this up for my girlfriend).