Saturday, July 16, 2011

Print Server for DD-WRT (simple version)

Since there's USB port on the router, any normal USB printer can become a network printer. As the router is usually on 24x7, there is no need to invest in a (usually overpriced) dedicated printer server.

The printer server program that we use here is p910nd. It's a very small (only 8KB) daemon which simply redirects all printing command from a PC to the printer. Setting up 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, which will be covered here.


Before we start, you'll need a USB hub if your router has only one USB port,
because we now need to connect a USB drive and a USB printer. As I said previously, I recommend a self-powered hub to prevent any power draw issues.


  1. Make sure the USB printer support is selected.
    In the web interface, under Services > USB
    * Enable 'USB Printer Support'
    * Click Apply Settings

  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/p910nd /opt/etc/init.d/S30p910nd


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

    Extra: using two printersUse this script instead

    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


  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 into the PC then run a manufacturer provided driver setup.

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

    I can't find a detailed 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 job, if your printer is well supported aka Linux friendly. However, things can get nasty for some GDI printers. 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 solutions with that.

3 comments:

Hi,

I'm using WZR-HP-AG300H, and the printing works out of the box. But I need your help re script...

I put these commands (in Administration/Commands):
p910nd -b -f /dev/lp0 0 -t 5
p910nd -b -f /dev/lp1 1 -t 5
p910nd -b -f /dev/lp2 2 -t 5

This where now I'm facing a problem, once the printer is removed/plugged or turned on/off, printing capability is lost, so I need to restart the router to enable that feature again. can you provide me a nice script for buffalo-based router?

Hoping for your kind assistance.

Thank you very much

Adrian

Sorry, I am extremely busy building a website that is deadlined in less than a week. I'm sure the nice folks at the dd-wrt site would whip something up. All you need to do is check if the server is recognizing the printer, and if not, restart p910nd.

ip doesnt work for me can any one help with belkin router issue?

Post a Comment

Note: Only a member of this blog may post a comment.