Saturday, June 26, 2010

Printer Server for DD-WRT(the simple version)

With USB port on the router, a normal USB printer can be hooked and become a network printer with wired or wireless capabilities. As the router is usually on 24x7, there is no need to invest a (usually overpriced) dedicated printer server or plug the printer around.

The printer server program we use here is p910nd. It's a very small(only 8KB) daemon which simply redirects all printing command from PC to the printer.

Setting p910nd on the router can be a snap or very comprehensive depends on the printer. The best scenario would be sharing a Postscript/PCL compatible one and will be covered here.

Before start, you'll need a USB hub if your router has only one USB port as we now need to connect a USB drive and a USB printer. Unpowered hub is good for USB flash drive or hard drive with external power supply while I would suggest a powered hub for hard drive solely relied on USB power to prevent overload or damage to the HDD.

  1. Set DD-WRT support for USB printer
    If you haven't done so, check earlier post step #2. Make sure the USB printer support is selected.

  2. Install p910nd server and run it as a service
    Log in from PuTTY and run
    opkg install p910nd

    Now create /opt/etc/init.d/p910nd(delete all previous contents if the file is not empty)

    source /mnt/root/.profile
    mkdir -m 755 -p /dev/usb
    mknod -m 660 /dev/usb/lp0 c 180 0
    sleep 1
    P910ND='/opt/usr/sbin/p910nd'
    kill -9 $(pidof p9100d)
    ${P910ND}  -b -f /dev/usb/lp0 0


    Then set it to run as a service

    chmod a+x /opt/etc/init.d/p910nd
    ln -s /opt/etc/init.d/vsftpd /opt/etc/init.d/S30p910nd


    Reboot or manually run /opt/etc/init.d/p910nd to make the change take effect.

  3. Install printer in Windows
    So we have p910nd running in the router now back to the PC(and Windows). First, you need to have the printer driver installed on the local computer. Exact procedures depend on the printer, but a foolproof way is to plug the printer back to PC then run manufacturer provided driver setup file.

    After driver installation, in Windows XP, follow this guide.

    Can't find a detail guide for Windows 7 but its essentially the same as earlier Windows editions. Anyway, here is a quick one:

    For Windows 7,  Open Control Panel->Hardware and Sound->Devices and Printers, then right click the printer icon. Select "Printer Properties" then click the "Ports" tab on the properties window.

    The default port might be USB001 that's for local USB port. Click "Add Port..." button, then select "Standard TCP/IP Port" from the list. Click "New Port..." which will open "Add Standard TCP/IP Printer Port Wizard". Click next and fill the "Printer Name or IP Address" with router's IP.
    add-printer-1
    After clicking "Next", Windows will try to detect the printer port and will fail. That's OK. On the next page, select "Custom" then click "Settings...". This will bring you another window, the default setting with Protocol Raw and Port Number 9100 should work. Confirm the change then back to original "Ports" tab. Select the newly added 192.168.1.1 port as default and click "Apply".

    Now plug the printer back to router and try to print from Windows machine.
     

This is a ten-minute work if your printer is well supported aka. Linux friendly. However, things can get nasty for some GDI printer -- just name a few, the popular HP Laserjet 1010, 1018 and 1020. Also, you might want the p910nd to run only when the printer is connected. To solve all these problems, we need to make the router aware of printer's status change(plugging or removal) and run commands upon that. This is called hotplug and we can make some really neat solution with that.

9 comments:

bane said...

For those who are using two printers, the startup script should look like this:


source /mnt/root/.profile
mkdir -m 755 -p /dev/usb
mknod -m 660 /dev/usb/lp0 c 180 0
mknod -m 660 /dev/usb/lp1 c 180 1
sleep 1
P910ND='/opt/usr/sbin/p910nd'
kill -9 $(pidof p9100d)
${P910ND} -b -f /dev/usb/lp0 0
${P910ND} -b -f /dev/usb/lp1 1

bane said...

Furthermore, when using the two printers, replace this line:
kill -9 $(pidof p9100d)

with this line:
killall -9 p910nd

resulting in this script:

source /mnt/root/.profile
mkdir -m 755 -p /dev/usb
mknod -m 660 /dev/usb/lp0 c 180 0
mknod -m 660 /dev/usb/lp1 c 180 1
sleep 1
P910ND='/opt/usr/sbin/p910nd'
killall -9 p910nd
${P910ND} -b -f /dev/usb/lp0 0
${P910ND} -b -f /dev/usb/lp1 1

This works better as it kills all p910nd processes running in the system.

Anonymous said...

typo on ln -s /opt/etc/init.d/vsftpd /opt/etc/init.d/S30p910nd?

Should be ln -s /opt/etc/init.d/p910nd /opt/etc/init.d/S30p910nd

Anonymous said...

Can someone help configure Brother HL-2030 on WNDR3700. Printer is on /dev/lp0 but even localy from the box no printing.

SuperRyu said...

My brother has some problems accessing the printer using a MAC. Are there some solutions for the MAC?

JP said...

I tried to use the PrintFab printer driver and it worked... Canon's CUPS driver doesn't work...

Kwomkwommr said...

Worked like a charm after installing the latest firmware. Thanks alot!

sarah said...

Call us at We24Support E-mail support number at 1-866-978-0799 and Enhance your system functioning and keep it clean with We24Support services.
E-mail Setup and support
email support

Sweet Fairy said...

Nice post with great details. I need a printer for home use for the Plastic cards printing purpose. Which one will be the best for me?

Post a Comment