Hacking the D-Link DNS-321 NAS

For some reason I derive immense gratification from hacking cheap commodity consumer devices and making them do much more than they were originally designed to. Not that I can’t claim all that much credit (as I generally just apply readily available hacks that others have figured out), but still…

Some of my favorite past hacks include:

  • Original Xbox: I haven’t played games on it for years, but with XBMC on it, it remains a formidable media center.
  • Buffalo WHR-G54S: Essentially a cheap Linksys router clone, but by replacing the stock firmware it can support features typically present on much more expensive routers (such as sophisticated firewall or QoS functionality). I was running the powerful dd-wrt firmware on it for a while, but later switched to the Tomato firmware (also here), which has most of the same features but is a lot easier to use.
  • Tivo: Back when I bought my first 40GB Tivo, I hacked it to add a 120GB drive (for a fraction of the normal cost).

My latest addition is the DNS-321 Network Storage Enclosure:

41XJJ24sDpL._SL160_.jpg

I was previously using an external USB drive attached to my Airport Extreme router, but decided that I wanted to upgrade to a less flakey and fully redundant (but still affordable) storage system for our home. The DNS-321 (or its older and slightly more featureful cousin, the DNS-323) fits the bill. Out of the box, it makes two SATA drives available over Gigabit ethernet via SMB. It supports both Raid 0 (striping) and Raid 1 (mirroring), but I’m using the latter for redundancy. With two 1TB hard drives, this gives me 1 TB of convenient, redundant, and reasonably fast storage, accessible from any laptop or desktop in our house (and our Xbox running XBMC). For solid performance as well as low power usage and noise, Western Digital Caviar GreenPower 1TB hard drives are highly recommended (and affordable, at around $110 each).

So all of this is already quite a decent package out of the box, but it can be extended much beyond these capabilities (and very easily, too!) All it takes is installing one of several hacks for the DNS-323 / DNS-321. The device turns out to be a full Linux computer (albeit with a small CPU and little RAM), and all it takes to enable all the Linux goodness is to copy a few files to the drive. It turns out that it looks for an executable file called fun_plug upon startup and executes this if it exists. Various hacks use this mechanism to deploy all kinds of applications, enable telnet or ssh, and more.

The simplest way to get started is to install the fonz fun_plug (also known as ffp). The instructions (or these alternative instructions) are pretty simple and straightforward to follow. After the installation, you are rewarded with telnet access to the device, but you will want to make sure to follow the rest of the instructions and set up a root password. I also recommend disabling telnet and enabling ssh instead. You now have a full Linux box at your disposal.

That’s pretty much where I’m at right now. I’m still trying to decide what to do with the device, but the possibilities are wide open. Many applications are either included with or available for ffp, including media apps like Mediatomb or Musicbrowser, server apps such as MySQL, Lighttpd, and PHP (allowing you to run a full LAMP stack!), P2P / Bittorrent clients like Transmission, rsync (so you can schedule offsite backups), subversion, and many more. Apps can be installed with funpkg, a simple package management tool.

There are also options beyond ffp, such as the apparently more powerful Optware package management system that can be installed on top of it. A huge number of packages are available for Opsware. This even includes Ruby and Git, so I’ll definitely have to play with this when I get a chance.

Not bad for a small $130 device. :)

23 Responses to “Hacking the D-Link DNS-321 NAS”

  1. SneezyPorcupine says:

    Awesome post man! Lots of helpful tips that I hadn’t seen anywhere else! =)

    I would love it if you can do a follow up on what you have been able to do with the drive since you started poking around. I just recently purchased the same DNS-321 with two Seagate 1TB drives.

    I am certainly looking to do more with the device as well. Especially if I can get something like an automated Bittorrent queing installed on it.

    I am fairly new to this whole 1TB+ deal, and find myself overwhelmed with thoughts of how I can fill up all the space. Currently, I am using it as a TV show database to download and catalog all the TV shows that I miss… But more importantly, I’m using it to manage my 40GB+ itunes database.

  2. Michael says:

    Thanks a lot for DNS-321 roundup. I also bought that NAS and started to hack it.

  3. @SneezyPorcupine, @Michael: Thanks for the comments!

    To be honest, I haven’t actually had a chance to tinker much with my hacked DNS-321. But it’s been doing a great job so far at the tasks it was intended for: Acting as a general file server, hosting my iTunes collection, etc.

    I have briefly tried out the built-in UPnP server with my Xbox 360, and it works well enough. Some of my video files don’t play, though, and I’m not sure if this is a limitation of the UPnP server or (probably more likely) the Xbox.

    I have also installed MLDonkey, as I thought this might be a good, lightweight bittorrent client (I had used this many years ago, although for regular eDonkey sharing). It worked OK, but I found that it bogged the device down too much, to the point where I wasn’t able to listen to iTunes songs stored on it. So I ended up uninstalling MLDonkey and will investigate other Bittorrent clients in the future.

    I’m also planning to set up a simple backup solution. Basically, I will set up a dedicated backup directory on the NAS (and possible some scripts on my laptops that automatically sync certain critical files / folders to the NAS), and add a cron job that uses rsync to upload the backup directory to an offsite location every night (such as DreamHost, my webhost, which includes free backup storage).

    I’ll definitely post an update to my blog when I’ve found any new, groundbreaking uses for my hacked DNS-321. :)

  4. [...] DigitalHobbit » Blog Archive » Hacking the D-Link DNS-321 NAS [...]

  5. Tony Kirkham says:

    Has anyone found an app that will extend the redundancy by adding automated restore snapshots at say the 6 previous hours and a week or months worth of daily snapshots? The drive and the redundancy have been working great for me, however I just ran into the experience where my wife loaded some pictures and then deleted them instead of moving them to another directory.

    If there was something like the snapshots available on a netapp on this box this problem could be recovered from, for a time that is.

    Thanks,

    -Tony

  6. Steven says:

    Can anyone tell me if I would be able to host a website from a hacked dns-321?? Please DM me on twitter @ Phelix16. Thanks everyone!!

  7. Steven,

    You’re not following me on Twitter, so I won’t be able to DM you. But here’s some info that might help anyway:

    I haven’t actually tried running a webserver on the DNS-321. But it looks like the easiest way would be to use the Lighttpd server that comes with funplug. You can enable it using these instructions.

    That page also has info on adding PHP support if you need it.

    I’ve also come across instructions on installing Apache (as part of a Subversion setup, but you can install that part).

  8. opus3 says:

    Does anyone know of plug-in that will allow the DNS-321 to support Open LDAP??

  9. AJay says:

    Thanks for the great instructions. Are you actually using rsync on the DNS-321 now? How do you like the performance?

    I am currently using cygwin-rsync to back-up my windows laptop, by mounting the DNS-321 disk. I find the performance to be very poor. Do you know if the performance would be better, if I install rsyncd on the DNS-321 and did an rsync using ssh, instead of mouting it as a networked hard-disk?

    Your help would be very much appreciated.

  10. @opus3: Sorry, no idea.

    @Ajay: Unfortunately I never got around to setting up rsync. As a Mac user, I’ve been mainly relying on TimeMachine. It’s definitely still something I want to set up at some point, to take care of off-site backups.

    I’d be surprised if the performance was any better with rsync + ssh than with SMB, but to be honest I’m not much of an expert on it. It’s certainly worth a try.

    Are you accessing your DNS-321 over WiFi or ethernet? Could it be that you’re just running into the limit of your WiFi connection? I’m getting significantly better performance accessing my DNS-321 when I plug my Mac in via ethernet.

  11. BoHunter says:

    I have the DNS-321 hooked to a Linksys WRT320N Gigabit router (used the cable that came with the DNS-321 to connect it). I have my PC with a gigabit NIC connected to the router and still only achieve a throughput of @ 100Mb. I have tried a few tweaks, including setting the priority up on the port on my router that connects to the DNS-321. I tried to force Gb connectivity via the DNS-321 setup. I also tried changing the packet size from 1500 to 9000 and several in between. None of this has proven successful. Getting about 10MB/sec throughput on this setup.

    Any tips on getting better wired throughput?

    Wireless (802.11 G), I’m getting 2.9 – 3.2 MB/sec transfter rates pretty consistently. Seems to be what I would expect.

  12. Sorry, I don’t have any tips. Your numbers sound pretty consistent with what I’ve seen. The last time I measured my data transfer (using a Gigabit switch and Cat6 cable), I reached around 15MB/sec.

  13. [...] or FreeNAS, but because of a number of issues, I gave up on that plan, and realized that the (eminently hackable) DLink DNS-321 was on sale for < $100 after rebate. That’s been loaded with a pair of 2TB [...]

  14. Jesse says:

    Hey is there a way to set the DNS-321 up to operate just like when you’re on the network? I want to be able to double click a video file and play it without downloading it over the internet when i’m traveling.

  15. James Atkins says:

    Thanks for the information. XBMC is the best media player..Ever!

  16. Jack Stuard says:

    I would like to know more information about developing to DNS 321, like if possible using Java.

    My idea: To build a jDownload application, for web. This way rapidshare, megaupload and a lot of others sharing web sites will be able to be downloaded by DNS 321

  17. Steve M says:

    I have had a DNS 321 for some time now and have had a WD 1TB drive in it working as network storage on ethernet and it has worked very well and reliably. Recently I wanted to double it’s memory and add an additional 1TB Hitachi drive to the second bay, but the device won’t recognize it. It flashes the drive light and spins the drive but will not access or list the drive as present. This drive is almost new and was working fine in one of my Windows XP professional running computers. Can anyone give me some ideas as to how to get the device to recognize and format this drive?

  18. Schoon says:

    Steve M, in doing research on this unit I read that the drive has to be completely fresh in order for the 321 to recognize it. I’m not sure if this is your problem but wanted to mention it. Hopefully you’ve already figured this out though based on the date of your post. I’m guessing a fresh drive would require a low level format only which I don’t even know how to do anymore these days in the windows world.

  19. Janos Marki says:

    As described in your intro, the best p2p-app for such a device is Transmission. I have it on my WD MBWE-II (which is very similar to your system, 2 disk NAS, Linux-hackable, however, the CPU is very weak), and it runs OK if you configure it well.

    As for the box, unfortunately, the data transfer rates (read-write) never go above 4 MBps (which is a bit annoying, considering that that does not even reach the 100 Mbps (~12 MBps) speed, and they brag about the Gigabyte ethernet adapter installed in it – what for, I don’t know, when the CPU can only cope with transfer speed that are a third of even a shabby 100 Mbps adapter… So I am thinking of changing at some point – how fast is this box?

  20. Janos Marki says:

    Now read through the comments, too… :-) Guys, those transfer speed are about 3-4 times higher than those of the WD MBWE-II. So definitely a big plus! Cheers and see ya!

  21. 1994MGoBlue says:

    I’m having a ball hacking my DNS-321! The fun_plug makes it so simple to get a root telnet prompt (which I immediately used to activate SSH and disable telnet). DH’s link to ALTERNATIVE INSTRUCTIONS I found easier to follow. From there I followed the instructions on http://www.inreto.de/dns323/fun-plug/0.5/ to rsync about 100 packages of familiar Linux tools and installed them all.

  22. Marc Wagoner says:

    I have been using my NAS box as storage for a home based business so that my other home based employees can exchange files. It works very well, but has a few quirks. The Box will not let internet access users move files from one directory to another. Is there a revision to my set up that needs to be made to allow this?

  23. Comcast Offers the Best Bundles Deals Three services are offered in one bundle by a leader in the cable industry, Comcast Cable. You can get their Digital Cable TV, Broadband Internet, and Phone Services all in one bundle deal. There are many benefits, but a lot of customers are saying ….

Leave a Reply