WikiDevi.Wi-Cat.RU:DD-WRT/Printer Sharing
DD-WRT allows for clientless printer sharing making it easy to install printers directly into the router without the need for a seperate computer. You must have installed USB support (usb_storage, sd_mod etc. can be left out if no need for external storage).
Some of the information below is outdated. I made a guide for how to get USB printing working on the Asus WL-520gU. It should also apply to other routers with USB. http://wl520gu.googlepages.com/
The following must be done via telnet or SSH:
Printer driver
Install printer driver:
ipkg -force-depends install kmod-usb-printer
Edit /jffs/etc/config/usb.startup and add
insmod /jffs/lib/modules/2.4.30/printer.o
Connect printers and reboot your router
See if any printers have been found:
dmesg | grep usb
It should show something like this (I have 2 printers connected)
<6>printer.c: usblp0: USB Bidirectional printer dev 5 if 0 alt 0 proto 2 vid 0x04F9 pid 0x000D <6>printer.c: usblp1: USB Bidirectional printer dev 6 if 0 alt 0 proto 2 vid 0x04A9 pid 0x108C
usblp0 means that the found printer is accessible at /dev/usb/lp0 etc.
Note: The 'USB Support' link above refers to installing several modules. On my WRT350N, I had to install these additional modules (usb-uhci.o and usb-ohci.o) to get my router to detect that my printer was plugged in.
comments from wmd1942:
I found the command "insmod /jffs/lib/modules/2.4.30/printer.o" is unnecessary if you have Core USB Support, USB 2.0 Support and USB Printer Support enabled in the 'Services' section of the router web page.
Notes For v24 Stable
The new v24 stable (i.e. not the release candidate versions) contains support for printer sharing and usb support in the web UI. I just got my printer server working and I figured I'd share my experience and maybe save somebody and hour or two.
Here's what I had to do to get my LaserJet 3020 to work with DDWRT on an Asus WL-500g Premium with the "DD-WRT v24 (05/24/08) mega - build 9526" version of the firmware:
1. Enable "JFFS2 Support" on the Administration tab.
(Note from another user: I had to enable "Clean JFFS2" as well, and reboot. After reboot, I ran "ipkg update", then installed the package mentioned in the first step of the "Printer Driver" section above.)
2. Enable SSH on the Services tab
3. Enable "Core USB Support", "USB 1.1 Support (UHCI)", "USB 1.1 Support (OHCI)", "USB 2.0 Support", "USB Printer Support" on the Services tab (all items under "USB Support" except for "USB Storage Support"). Note that the router did not recognize my printer if I left the USB 1.1 drivers unselected. This even though the printer supports USB 2.0.
4. Connect your printer to the router
5. Reboot your router
6. Log in with SSH to your router. And check if your printer was recognized:
root@my-ddwrt-router:/jffs/etc/default# ls -la /dev/usb/ drwxr-xr-x 1 root root 0 Jan 1 1970 . drwxr-xr-x 1 root root 0 Jan 1 1970 .. crw-rw---- 1 root root 180, 0 Jan 1 1970 lp0
if there is nothing in /dev/usb/ you need to change something, probably involving installing some other driver for your printer.
7. Look at the following files:
/jffs/etc/default/p910nd /jffs/etc/init.d/p910nd
To do so, type: vi /jffs/etc/default/p910nd. vi is a text editor. You start in "command mode". Press 'a' to switch to editing mode, where you can edit the file. Press 'Esc' to get to command mode. Press :w[enter] to write (save) and :q[enter] to quit without saving, or :wq[enter] to save and quit.
At least on my version of v24, the third line in the startup script had the following line:
DEFAULT=/etc/default/p910nd
this was invalid on my router (people more familiar with the router, please correct me here or explain the intricacies involved) and I had to edit this file and change the line to say:
DEFAULT=/jffs/etc/default/p910nd
there are two commands that you can run to check if the server is running:
root@my-ddwrt-router:/jffs/etc/init.d# netstat -an Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:9100 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
root@ddwrt-se-office:/jffs/etc/init.d# ps | grep p9100d 561 root 680 S p9100d -b -f /dev/usb/lp0 0
If you see a 91xx port listening in netstat and you see the p9100d running in ps, your server is probably up and running properly. Check that the server is not running yet. If not, test starting the the server by issuing:
/jffs/etc/init.d/p910nd
For v24_TNG (sp2) versions, the command should be:
/jffs/etc/init.d/p910nd start
and check that it came up. You should be able to print now (see bottom of this page for instructions on how to set up your workstation for IP printing via ddwrt).
8. Add the above command to the Administration->Commands edit box and click "Save Startup". This makes sure that the printer server comes up the next time you reboot your router.
Hope that helps. --Mbjarland 07:33, 27 June 2008 (CEST)
Note: On my DD-WRT v24-sp2 (10/10/09) mini-usb-ftp the command: '/jffs/etc/init.d/p910nd start' works on the ssh shell, but not on the Administration->Commands edit box
This commands works on the Administration->Commands edit box:
/jffs/usr/sbin/p910nd -b -f /dev/usb/lp0 0
Print server
Now Install printserver daemon:
ipkg install p910nd
Edit /jffs/etc/config/usb.startup and add
#brother laser /jffs/usr/sbin/p910nd -b -f /dev/usb/lp0 0 #canon inkjet /jffs/usr/sbin/p910nd -b -f /dev/usb/lp1 1
(correct the above to match your setup)
Eliminating the -b flag may resolve failure to print for some printers.
NOTE from another user: I needed go without the -b flag on my Canon MX310 printer for it to work.
-b means bidirectional, -f specifices device name, and the last number can be 0,1 or 2, making the print server listen at port 9100, 9101 and 9102 respectively.
Reboot your router
Now, you router works as a print server over TCP/IP
Note: You may have to remove the '-b' option for p910nd. I couldn't print with that option included.
comments from wmd1942:
In order to load the printer server in startup, the execution permission has to be added to this "usb.startup" file:
root@WikiDevi:DD-WRT/chmod +x /jffs/etc/config/usb.startup
After reboot, use command:
ps | grep p910
The screen should be something like:
root@WikiDevi:DD-WRT/~# ps | grep p910 306 root 356 S /jffs/usr/sbin/p9100d -f /dev/usb/lp0 0 n
NOTE:
Multifunction printers which have fax machines attached to them may also be made to work. Ie: A CANON MF4150 with VendorID=0x04A9 and ProductID=0x26A3 will have lp0 and lp1 available. Running two instances of p9100 on different ports (9100 and 9101) and creating the respective port in windows will allow fax functions to work in conjunction with print functions as long as proper drivers are used to access the proper port. Most printers have print functions listed as lp0 and fax functions list as lp1.
EXAMPLE:
#canon printer /jffs/usr/sbin/p910nd -b -f /dev/usb/lp0 0 #canon fax /jffs/usr/sbin/p910nd -b -f /dev/usb/lp1 1
Workstation setup
CUPS Web Interface
- Make sure that the CUPS service is up and running
- Open http://localhost:631 in you web browser, assuming that you are running the CUPS server locally.
- Click the 'Administration' tab
- Click the 'Add printer' button under 'Printers'
- Choose 'AppSocket/HP JetDirect ' and click 'Continue'
- Enter 'socket://HOSTNAME:9100' where HOSTNAME is the ip address of you router (normally 192.168.1.1). 9100 is for the first printer, 9101 for the second etc. Click 'Continue'
- Go on with the printer wizard to select brand, model and settings as you would do for a local printer. As a general rule, PPD files are provided by printer driver packages and put in /usr/share/cups/model.
Ubuntu Linux
- Go to System, Administration, Printing.
- Click New Printer
- Choose AppSocket/HP JetDirect
- Hostname: IP address of the wireless printer (normally 192.168.1.1)
- Port: 9100 for first printer, 9101 for second printer, etc
- Click Forward and go on with the printer wizard to select brand, model and settings as you would do for a local printer
Windows XP
- Find your printer in Control Panel - Printers etc. and open the properties page for it.
- Select the Ports tab.
- Click Add Port and choose Standard TCP/IP printer port and click New Port
- Enter you router's IP address (normally 192.168.1.1) and click Next
- Set Device type to custom and click settings.
- Make sure RAW is selected and specify the necessary port number (normally 9100, 9101 for second printer, etc) and click OK
- Click Next and Finish and Close
- Make sure the newly created port is selected for your printer and click OK
Mac OS X 10.5 (Leopard)
- Open System Preferences
- Open Print & Fax
- Click the + button below the list of installed printers
- Select the toolbar button called 'IP'
- Set protocol to: HP Jetdirect - Socket
- Enter the address of your router followed by : and the port - ie. normally 192.168.1.1:9100
- Leave 'Queue' blank
- Set a friendly name for your printer (whatever you like)
- And a friendly location (again, up to you)
- Print Using: choose 'Select a driver to use'
- A list will pop up of all installed printer drivers - choose the one that works for you (see Note below)
- Add your printer
Note (Mac only): the driver must be compatible with the CUPS printing system, which is one of the two printing systems included in OS X. Certain printers e.g. Canon Pixma series and Epson Inkjet include OSX drivers which do not use CUPS. You may find compatible printer drivers from Gutenprint (free) or PrintFab ($). OS X Leopard appears to include certain Gutenprint drivers, but the quality may vary and it may be worth checking their website for updated versions, or try PrintFab.
Printing from WAN
If you want to be able to print from the WAN side of your router do the following:
In the web interface go to Administration - Commands and hit the "Command shell" field and type in
/usr/sbin/iptables -I INPUT 1 -p tcp --dport 9100:9102 -j logaccept
And click Save Firewall
Your router reboots and you can now print from WAN side
NOTE: This is not recommended if your WAN is directly accessible from internet, but useful at private subnets of companies, colleges etc.
Installing on Asus WL500G Deluxe, with DD-WRT v24-sp2
Install dd-wrt.v24_usb_generic.bin firmware Enable JFFS, and clear JFFS Enable SSH reboot router Enable All USB options - set mount point to /opt Since ipkg update seems broken, Download http://downloads.openwrt.org/backports/rc5/p910nd_0.7-2_mipsel.ipk to a USB stick formatted with FAT32 Insert USB into router and reboot router SSH to router cd /opt ipkg -d root install p910nd_0.7-2_mipsel.ipk
p910nd is now installled and you have the configuration files in /jffs/etc/ and you can continue at the guide above.
Notes for K26
With the new kernel 2.6 the kernel doesn't create the device file /dev/usb/lp0 anymore. You have to do that manually once. Just issue
mknod -m 660 /dev/usb/lp0 c 180 0
once and everything is going to work. This should probably be done before starting the p910nd server.
Note from another user: I had to add this mknod command to /jffs/etc/config/usb.startup.