D-Link DNS-323 as print and scan server (part 1)

Even if I feel like doing too many things at the same time that has never stopped me playing around with a new gadget. This time I’ve added the D-Link DNS-323 NAS device to my home office so I can have automatic, reliable backups soon. The device itself is really cool, with some nice services (e. g. an iTunes server) and a USB port for hooking up external devices. Adding a printer there turns the box into a print server. The most important feature to me for picking this product from the range of comparable products, though, was its openness. There is no need to install any proprietary software on the client, and it runs a Linux kernel, which makes it really open for software extension.

The print server was absolutely a feature I wanted to use. So I hooked up my Samsung ML 2010 printer to the USB port of the NAS device, changed my printer definition on my gutsy clients to the samba queue “lp” on the IP address of the DNS-323, and lo and behold: Printing worked out of the box. (This is making a long story short because printing did not work from my laptop due to an average of 60% packet on the powerline home link between the WLAN access point and the gigabit network hosting the DNS-323. But that was fixed by adding two separate power outlets.) I read that the 1.4 version of the firmware fixes an issue with the disks not spinning down when using the print server alongside with UTF8 issues and installed that.

What of the scanner now? Leave that attached to the home PC? Of course not! But as there’s no scanner service running on the box as it comes off the shelf, this started my quest for how to extend the services on the DNS-323.

Definetely the most important resource I found is the DNS-323 wiki. It has loads of information, howtos, forums, etc. Basically, for extending the device there are three options documented on that site:

  1. Use a fun_plug script to start up services after the box itself has started,
  2. Install Linux into a chroot’ed environment,
  3. Flash the device to run Linux natively.

Variant 3 definetely looked like it would be beyond my hardware modding skills or ambitions (you first need a serial port). Variant 2 still looked too complicated for my taste. So, I started with the fun_plug. On the wiki there are links to a ready-to-use fun_flug framework, called ffp. First I installed version 0.5 beta and it looked quit good. However, I soon found that it didn’t have nearly as much additional software pre-compiled for the box’s ARM processor as I was hoping for. There is, however, the optware project originally targeted at Linksys routers which has a considerable number of software packages ready and helpful instructions for adding further software. Optware recommends using the stable version 0.4 of ffp. That is because that uses libraries provided by the firmware in a number of instances where 0.5 brings its own libraries. That in turn saves some disk access, and as I decided only to use ffp for providing a mechanism to start services, that’s fine for me.

After bootstrapping the optware framework (again see the DNS-323 wiki), I installed the sane-backends package, configured saned.conf to allow network access from my local network, started the daemon, configured sane on my clients to query the DNS-323 … and could scan. At first, the sane client would always ask me to select from two scanners. That was because my epson scanner is served by two variant epson drivers for sane. To solve that, I edited sane’s dll.conf on the DNS-323 and made sure of the two lines “epson” and “epson2” only one was active by commenting the other with a “#”.

Then I needed a way to start the sane service automatically, so here’s what I added to the fun_plug.d/start directory:

1. A link to /opt/etc/init.d/S01sane-backends for adding the sane-port definition to /etc/services on each reboot. Make sure that script is executable: ln -s /opt/etc/init.d/S01sane-backends /mnt/HD_a2/fun_plug.d/start/04sane-backends.sh

2. A script to start xinetd (which can be installed from the optware repository) 05xinetd.sh:

#!/bin/sh

OW_SBINDIR=/opt/sbin

xinetd_start() {
if [ -x "${OW_SBINDIR}/xinetd" ]; then
echo "Starting inetd... "
${OW_SBINDIR}/xinetd
else
echo "ERROR: inetd not found or not executable"
fi
}

xinetd_stop() {
killall xinetd
}

xinetd_status() {
if [ -n "$(pidof xinetd)" ]; then
echo "running"
else
echo "stopped"
fi
}

case "$1" in
stop)
xinetd_stop
;;
restart)
xinetd_stop
sleep 1
xinetd_start
;;
status)
xinetd_status
;;
start|'')
xinetd_start
;;
*)
echo "Usage: $0 start|stop|restart|status"
;;
esac

That’s that. Are we done? Not quite, because now that I can scan and print without using my home PC, I want to be able to make photocopies without PC, too.
But that’s a topic for my next post.

Advertisements
Tagged , , , , ,

9 thoughts on “D-Link DNS-323 as print and scan server (part 1)

  1. bonky says:

    This blog is pretty interesting, will add a bookmark, thanks.

  2. hal says:

    Nice tutorial, you should add this to the DNS-323 wiki for others to enjoy.

  3. Thunder says:

    Hello there,

    Is there any way I can stop/review any print before it goes to my printer?

    I mean using this dns323?

    Thanks

  4. Not quite sure what you mean here, Thunder.
    You want to hit print on your PC to send it to the DNS323, then have the DNS323 wait for your confirmation before it actually sends the document to the printer?
    Well, haven’t tried it, but I suppose it should be possible to pause the printer queue thoudh the samba config somehow. But whether you could actually get the spool file created from the DNS323 and actually view it, will depend a lot on your printer. It might actually be feasible, if you have a post script printer. All definitely very hackish.

  5. Tony says:

    Interesting post and I read part 2 and 3. I have a question regarding using the DNS-323 with two printers. I am sucessfully using it with one connected to three XP PCs. I would like to attach two printers using an USB hub. Can the DNS be set up to do this. I am not too familiar with Linux and would thus really appreciate your help.
    Thanks

  6. Well, it is certainly possible. I suppose it will require some tinkering, though, which will be a bit tough, if you don’t know Linux to some depth.
    The key is this file: /usr/local/LPRng/etc/printcap
    It contains the printer definition for the default printer.
    lp|USB Printer:\
    :sh:\
    :ml=0:\
    :mx=0:\
    :sd=/mnt/HD_a4/.lpd:\
    :lp=/dev/usblp0:\

    You would have to plug in your second printer and see what device is generated (with dmesg). It’s prolly going to be usblp1. Then you would need to add a second section to printcap with the first lp changed to lp1, the sd pointing to a different directory (you need to create first), and the second lp pointing to the right device. Watch that you leave an empty line between the printer definitions. Then you need to kill lpd and restart it. I don’t know what it is in the DNS that makes it read the printcap from that strange directory (rather than /etc/printcap) … so maybe that needs some tweaking, too.
    And finally if everything works (check with lpq -a on the DNS), you need to add all those steps to a script that is automatically executed on each restart (fun_plug).

    Bit tough, perhaps, but should be doable.

  7. Noel says:

    Hi Karl. I tried connecting my Lexmark 8300 printer to the USB port of the DNS-323 but I couldn’t figure out how to print or scan through my PC (connected to a router & the DNS-323). There seems to be no communication between my PC and the 8300 printer.

    (I have another laser printer attached to the router as my default network printer. Does this matter? )

    Where and how do I “change my printer definition on my client to the samba queue “lp” on the IP address of the DNS-323” ? That’s where I got lost. Pls help. Thanks.

  8. Noel,
    that depends a lot on your client (Windows, Linux (which distro), Mac). The client OSes typically have something like “printer settings” where you can “add a printer”. Then you tell the configuration that it is a network printer you want to add, and then there is typically some sort of tool to let you browse the network, or you might be able to specify the printer queue directly. On Windows that might look like \\192.168.1.2\lp (where 192.168.1.2 is just an example for the IP address of your DNS 323).
    Scanning won’t work OOTB, I’m afraid, though.

    Karl.

  9. Telekom says:

    nice info thank you

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: