Saturday, June 26, 2010

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.

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

Install p910nd server and run it as a serviceLog in from PuTTY and runopkg install p910nd

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

Then set it to run as a servicechmod a+x /opt/etc/init.d/p910ndln -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.

Install printer in WindowsSo 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.

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.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.