This has been so painful.
I’ve spent hours trying to get this working with little info on google searches for when things have gone wrong.
Fortunately, I have got it working! Hopefully this guide will be of some help if you’re trying to get CUPs working on your wireless router.
What is CUPs? printing….from your wireless router???
CUPs is a linux print server. Using a wireless router, such as the TP-LINK WR1043ND, we’re able to install a new open source firmware such as OpenWrt, and further install different packages, such as CUPs, allowing us to do a lot more with our devices than the manufacturer originally intended.
Issues upon issues…
My first attempt at this saw many different issues. If you really want to see what I was struggling with, I have a forum post about them here: https://forum.openwrt.org/viewtopic.php?id=39990
A fresh start
It was time I started again from scratch. I decided I would try out a bleeding edge build and I am now running OpenWrt Attitude Adjustment 12.09-beta, LuCI Trunk (trunk+svn9220). My reason for this is the off chance a package I had installed may have been having issues with “stable” which hasn’t been updated in almost a year (http://downloads.openwrt.org/backfire/10.03.1/ar71xx/ shows Dec 2011).
– TP-Link WR1043ND Wireless router
– 10 port powered USB hub (overkill but I got it cheap. The WR1043ND doesn’t do a good job providing power to USB devices, so without a powered hub, you may see strange issues, especially with USB 3G modems.)
– 2GB USB stick (This will be used for spooling for CUPs)
– Brother HL5240 Laser Printer
– Canon MX310 Multifunction Printer
Step 1: Install OpenWRT on your wireless router.
There are enough guides online on this, and I won’t cover it here. All I’m going to say is if you’re currently running OpenWRT and you want to try another version of it, login to your router via the web, then System > Backup / Flash Firmware > Flash new firmware image.
Normally you would download a sysupgrade .bin but I used a factory.bin. This is because I was going between different versions of OpenWRT and I’m not sure if a sysupgrade version may have caused issues. I also unticked “keep settings” since I wanted it back to default config.
Flash the firmware then re-setup any of your basic config (passwords, ip address, wireless SSID etc).
Step 2: Prepare your router for CUPs
At this point, you’ve probably already seen the CUPs guide on the OpenWRT site and are probably stuck on it. Hopefully the below steps will be of some help.
For me running ATTITUDE ADJUSTMENT (12.09-beta, r33312), all the required usb packages were already installed. You can check what packages are installed by entering opkg list-installed, or via web by going System > Software.
Basically before you install CUPs you need:
I think you may also need kmod-usb2, and hotplug2. I have them installed anyway.
CUPs also needs:
zlib, libpthread, libpng, libjpeg, libstdcpp, and if you’re using a canon printer, you may need cups-bjnp. Note, for all of the above, except cups-bjnp, they may be dependencies for CUPs and I didn’t have to manually install any of them. I have a feeling they all just installed when I installed CUPs.
opkg install kmod-usb-core kmod-usb-ohci libusb kmod-usb2 hotplug2
Make sure you don’t have kmod-usb-printer installed or running.
Why? because CUPs talks directly to the printers and kmod-use-printer is another layer which is used by other apps such as p910nd to communicate with the printer. This is also the reason why you won’t see lp0 under /dev.
Right! Prerequisites are out of the way, lets actually install CUPs!
Step 3: Installing CUPs
From the command line: opkg install cups
That was probably the easiest step of the lot.
Now that CUPs is installed, there’s a bit of config you need to do before it will probably work. As detailed on a forum post on www.newren.com.au, you need to do the following:
Use a text editor (e.g. vi) to open /etc/cups/cupsd.conf, so:
root@OpenWrt:/# vi /etc/cups/cupsd.conf
And change AuthClass to AuthClass Anonymous.
Remember to change allowed network to your network, otherwise you won’t be able to find the printer. E.G:
Allow From 127.0.0.1
Allow From 192.168.0.0/24
Change “Allow From 192.168.0.0/24” to the IP subnet you’re using.
Use “:wq” to save the file and quit. Personally I prefer using the text editor nano, so I did opkg install nano, and then nano /etc/cups/cupsd.conf, edited the file, then ctrl + x, Y, enter.
Then, you need to change the permissions on /usr/lib/cups/backend/usb to 700.
To do this, enter: chmod 700 /usr/lib/cups/backend/usb
This changes the behavior of cups, which normally tries to execute the backend through a user account other than root. This forces the backend to run as root from cups.
Okay! Got this far? Try entering the following command:
You should hopefully see something like:
direct usb://Canon/MX310%20series?serial=406F4E&interface=1 “Canon MX310 series” “Canon MX310 series” “MFG:Canon;CMD:BJL,BJRaster3,BSCCe,PLI;SOJ:TXT01;MDL:MX310 series;CLS:PRINTER;DES:Canon MX310 series;VER:1.030;STA:10;HRI:EU;MSI:E3;” “”
Yus! This is a good sign! This means that CUPs is talking correctly with your printers. Get an error? I originally had:
/usr/lib/cups/backend/usb: can’t load library ‘libusb-0.1.so.4’
root@OpenWrt:/usr/lib# opkg update
root@OpenWrt:/usr/lib# opkg install libusb
Step 4: Accessing CUPs
To access cups, enter http://ip-address-of-your-router:631/admin, so for me it’s http://192.168.0.1:631/admin
You may be requested to login, just use your root account, unless you’ve created another account.
Next go Admin > Add Printer, and you should be presented with the following screen:
As you can see, CUPs HAS picked up both my printers correctly, and I’m able to go through each following step in setting them up. What if CUPs doesn’t show anything there for you?
Try the following, which was posted on http://9m2tpt.blogspot.co.nz/2012/01/cups-hl-2140-usb-printer-wzr-hp-g300nh.html:
To add the printer, just go to http://your-router-ip-address:631 Go to administration, add printer, select the AppSocket/HP JetDirect option. Remember the output from /usr/lib/cups/backend/usb? Use the URI there and paste it into the “Connection” field. Example, for my printer, the URI returned by the backend command is:
Okay! So if your printers DID show up and you didn’t have to do the paragraph above, select your printer and click next. There’s two ways you can install your printer. You can either install it as RAW, or you can install a PPD file for your printer. Without going into detail, I believe you’re better off installing using a ppd file. If my case with the Brother HL5240, I was able to get the ppd file from: http://www.openprinting.org/printer/Brother/Brother-HL-5240
Go through all the steps and you should have your printer sitting as idle under printers. At this point, you should be able to add your printer on a client and try printing a test page.
Note: Due to limited functionality of CUPs on the router, you can’t print a test page from within CUPs on the device.
Step 5: Configuring a Windows 7 Client for the CUPs Printer
1. Click Start, and type add a printer.
2. Click add a network, wireless, or Bluetooth printer.
3. Click “The printer that I want isn’t listed.”
4. Select the second option, and paste the full URL to the printer. In CUPs, select Printers > followed by the printer itself. The url in your address bar is what you should paste below. Then install the correct drivers for your device. On the last screen you could click “print a test page” followed by finish.
At this point, hopefully a test page has printed. Wohoo!!
I spent hours getting to this point. And it’s a fantastic feeling having your wireless router act as a print server. The thing to remember is, it’s not over yet….
Configure a USB drive for spooling storage
One issue that we face having a wireless router act as a print server, is that this wasn’t its original function, and therefore there are certain constraints that we must get around. 1 is that the router has an extremely small and limited internal memory. With CUPs, when a user sends a job to the printer, the whole file gets transferred across, and needs to be stored, or cached somewhere while the printer gets ready to start printing. Therefore, we need to set up a usb drive for spooling. You may get away with not having to do this step, but you also may have print job issues down the track if you’re printing a big file. Chances are you have a spare usb flash drive lying around not being used, so why not just do the extra step.
For this step, there are other guides online for configuring a flash drive for OpenWrt, not to mention the OpenWrt usb storage page. There’s quite a good guide on it here. For me though, I have a linux Mint laptop, so I just plugged in my spare usb drive, apt-get installed gparted, and then configured 90% of the flash drive with ext4, and the last 10% as SWAP. I also changed the permissions on the flash drive and used permissions you probably shouldn’t use by doing “sudo chmod 777 /mnt/flash drive” which basically gives all users read write and execute permissions. For me I don’t think there will be any issues with this.
Following the guides above, I did:
opkg install kmod-usb-storage kmod-fs-ext4 block-mount
At this point there is two ways you could mount your storage, either using the CLI/SSH or via the gui web page. Personally doing it with the web page, as I find it easier.
If you don’t have the tab “Mount Points” it’s probably because you don’t have all the right packages installed. It didn’t appear for me till I added “block-mount”.
Next reboot your router and make sure the usb device comes up mounted correctly on the above page. At this point it may be a good idea just to do a blank page print to your printer to ensure everything is still working fine. Okay next step!
Configure CUPs to use your USB device for print jobs
Time to re-edit your CUPs config. Either use VI or your text editor of choice and edit your cupsd.conf file:
I changed both to /usb/cups/ since as you can see in the above screen cap I mounted my usb drive as /usb
You probably should restart CUPs now.Do this by:
root@OpenWrt:~# /etc/init.d/cupsd restart
Also if at some point you’ve restarted your device and CUPs hasn’t started, do either of the following:
enter “/etc/init.d/cupsd enable” or alternatively in the gui go to System > Started, and make sure cupsd has enabled beside it.
Speaking of cleaning up
Could be a good point to get rid of those default printers you’re not using.
Firstly stop the cups service: /etc/init.d/cupsd stop
I just commented out the printers doing nano /etc/cups/printers.conf and putting a # beside them eg #<Printer LP> and #<DefaultPrinter USB> syslog will throw up a couple of errors on start up but that shouldn’t matter. Alternatively just delete everything for the two defaults.
Adding the printers on a Mac Client.
I had issues adding the printers through the default mac config, but then suddenly remembered that Macs actually run a local version of CUPs so I just added them by going into the web browser http://127.0.0.1:631 and adding the printers in there! Works great!
Hopefully you made it this far, and have a working version of CUPs on your wireless router! Congrats!
Got an issue that you’ve been stuck in for hours? Always try doing some debug, E.g. via the web interface, go Status > System Log, or Kernel Log. Both of which can be pretty helpful.
As a last resort, if you’ve really stuffed things up, a fresh install might be the way to go. Fixed things for me!
Got any questions? feel free to write below.
Quite a good guide if you’re wanting to use p910nd as your print server:
USB flash drive on OpenWRT 10.03 Backfire HOWTO:
Other CUPs on OpenWrt install guides around the web:
Another all in one guide which covers pretty much everything except a print server:
Thanks very much. I’ve tried that on Backfire box and it works. Especially that chmod part was what I missed. I have HP printer so I installed also hplip, so I chmoded backend/hp instead of usb. Since then Find new printer worked but only raw queue seems to work but haven’t tried a lot.
Glad to hear that was of help! Yeah I possibly could have mentioned something about HP printers, but not having one I didn’t have to do any config regarding it. In terms of only raw queue working, have you tried installing PPD files for your printers? To be honest, I’m not sure if that was needed, but I did it anyway for both my printers. The other thing to mention, have you got the windows/mac drivers (depending on your OS)? On each machine, I installed the network printers with the actual drivers, rather than RAW. Works for me on all the devices I’ve tried. I guess it’s a matter of potentially finding the drivers though.
Next step for me is to try get scanning working (using SANE).
There is no problem to have the printer as RAW queue (precisely “Driver: Local Raw Printer (grayscale)”). We have also Windows PC. So the printer is added to Linux/Win systems by URL with appropriate drivers from system. It seems to me as best possible option. I’d like to have SANE working too, but there is even less resources of information then these about CUPS. You will hear from me as soon as I discover something.
Hi again, yesterday I have made SANE working. I think main problem is to have propper backend such as hp.conf or any else in /etc/sane.d/. I wrote down what I did, maybe something help you, but I did everything what I have found and I don’t know whether everything written is required or something still missing.
Hey sorry about the late reply. I appreciate the comment and it’s fantastic you’ve written a guide. I still intend on looking into this. Just haven’t found the time to try it out myself.
To enable a CUPS printer on MAC, just install the PPD and use URL lpd://router.name/printername
thanks for the howto. It worked for me but my TP-link needed some tweaking because it needs to upload fimrware to my HP laserjet P1005. Maybe you can add the following to your HowTo?
The above installation worked well but when I wanted to print something, nothing happens. There is a job in the job que and it also calls it finished. This is because the printer needs firmware uploaded via USB to function properly.
Download the appropriate firmware for your HP laserjet from: http://oleg.wl500g.info/hplj/ and put it in /usr/lib.
Then use the following command to upload the firmware to the printer:
DEVICE_URI=”usb://HP/HP%20LaserJet%20P1005?serial=BB0417Y” /usr/lib/cups/backend/usb 1 1 1 1 ” /usr/lib/sihpP1005.dl
Where “usb://HP/HP%20LaserJet%20P1005?serial=BB0417Y” needs to be replaced with yours. You can find it by using the /usr/lib/cups/backend/usb command.
The next thing to do is to create some hotplug script to upload the firmware each time the printer turns on. I will put it here when I have a working hotplug script.
#Hotplug script to auto upload firmware on connect or power on with CUPS USB backend
#Path to your firmware (for HP FW see http://oleg.wl500g.info/hplj/):
#$Product = IDvendor/IDproduct/bcdDevice (get it with lsusb -v)
if [ “$PRODUCT” = “3f0/3d17/100” -a “$ACTION” = “add” ]
logger -t HotplugScript Activating HP LaserJet FW upload script…..
logger -t HotplugScript Sending firmware to printer……
DEVICE_URI=”usb://HP/HP%20LaserJet%20P1005?serial=BB0417Y” /usr/lib/cups/backend/usb 1 1 1 1 ” $FIRMWARE
logger -t HotplugScript done!
Save it in /etc/hotplug.d/usb
Cheers. I’m sure this will help someone. Just added a link to the comment on the OpenWrt CUPs wiki page.
I’ve followed your steps for adding a printer under Win7. When I try to add my printer in the Windows configuration dialog (“http://192.168.0.3:631/printers/HP_LaserJet_1200”), I always get the message “cannot connect to printer”. Any ideas for help? 🙂
the problem is solved. You have to activate the online print support under Win7.
Having issues getting my printer listed when running this command. Any advice?
I’m currently overseas and not really able to offer that much advice.
Not knowing anything about your setup my suggestions can only be:
– Reread the stuff above that point in the guide.
– Are you able to try another printer and see if it detects it?
– could also be your version of openwrt. As above I had issues with certain versions.
– if you are using a USB hub make sure it’s a powered one.
– you haven’t tried installing p910nd or something else that attempts to take control of printers or USB devices? If so, personally a re install of openwrt might be the best option.
If nothing above is helpful, more info about your set up would be e.g. devices you’re using and connecting, version of openwrt etc.
Pingback: OpenWRT a CUPS | Honzův blog
I followed your great guide. I’m stuck however with one problem.
Printing txt files, printer self-test pages or webpages from chrome is no problem. When I try to print a docx or pdf file, I does not work. I already increased CUPS cache but that didn’t help.
Hmmm. I wonder if its worth trying to find some different drivers for your printer? My understanding of printers is you have two types of drivers, postscript and PCL. I forget which does what, but from memory one simply sends the file straight to the printer and the printer does the processing, and the other processes the file on the computer first before sending to the printer. I could be talking rubbish here but it could be worth looking into.
I have followed the instructions that you make. cups already recognize the printer, but when I will access the cups, I can not cant the admin page of cups (http://192.168.1.1:631). Any ideas for help? 😀
I presume 192.168.1.1 is in fact the IP address of your OpenWRT device?
Are you sure you followed Step 3 onwards correctly? you need to make sure your wireless routers IP subnet is permitted.
Also worth confirming cups is actually running:
root@OpenWrt:~# ps | grep cups
1596 root 4192 S /usr/sbin/cupsd -C /etc/cups/cupsd.conf
If it’s not, enter:
I have the same problem but in my case cupsd will not even start.
When I run:
cupsd: Child exited with status 1!
cupsd is enabled in System > Startup and I cannot find the CUPS log in /var/log/cups/error_log (I tried setting the LogLevel to debug just to try and catch any startup errors but nothing.)
Do you have any idea where to look into why cups is not starting? Since there is no cupsd process, the admin panel is unavailable.
Also, thank you for the blog post, it really simplified the CUPS installation process! 🙂
I’m really not too sure sorry.
I wonder if cups initially installed properly. I also wonder if the current cups version in the repo is compatible with all versions of OpenWRT.
I don’t actually use Cups anymore, as I now just have 2 network printers, so my knowledge of cups and openwrt isn’t as good as it was 2 years ago when I did this.
If you do manage to figure it out, I’d suggest following up to your comment, in case someone does a google with the same problem.
Sorry for late respon your advice. my network printer done after I enter /etc/init.d/cupsd start
but I still confuse,
i runs 3 printers on my router, and it all worked. When I configured my laptop to add printer, one of the printer (hp deskjet 3900) wasn’t listet in add printer wizard. So But, when I used other laptop, the printer was listed.
would u like to explain me this case?
Thanks a lot 😀
“When I configured my laptop to add printer, one of the printer (hp deskjet 3900) wasn’t listet in add printer wizard.”
I assume you mean when you’re trying to add the printer on your PC.
In other words, the printer shows up within CUPs.
Are you sure you did Step 5 above correctly?
If the issue is something more than this, I’m not sure if I can help. I now only have network printers, and don’t use CUPs or OpenWRT anymore.
Okay Matt, Finally I add the printer by took the driver printer i had download and it worked.
this article help me so much. thanks a lot 🙂
Just setup Brother HL-1110 following your instructions without ppd. Tried using p910nd but failed. I am a first time openwrt user, thanks so much.
Openwrt is installed on Planex MZK-W04NU.
Glad I could help! Thanks for the feedback 🙂
For HP laserjet 1020 I added additioanal “1” to
DEVICE_URI=”usb://HP/HP%20LaserJet%201020?serial=FN0Y1VL” /usr/lib/cups/backend/usb 1 1 1 1 1 $FIRMWARE
Not it works.
if [ “$PRODUCT” = “3f0/2b17/100” -a “$ACTION” = “add” ]
DEVICE_URI=”usb://HP/HP%20LaserJet%201020?serial=FN0Y1VL” /usr/lib/cups/backend/usb 1 1 1 1 1 $FIRMWARE
I followed this guide but with a HP Photosmart 7350 and it works perfectly fine in Windows for printing but in Linux it prints a line of random characters and spits out the paper. It continues to do this until I cancel job. I specifically use Mint 17.1.
To me this sounds driver related. I would be googling for similar issues with using printers on linux.
thanks or the Write-up – even it’s an older blog, it helped me finally getting a Canon L400 up and running with CUPS (OpenWRT 14.07)
I think the hook were the modifications in Cupsd.conf
Thanks a lot!
Hey thanks for your feedback Markus!
Glad this guide was helpful for you! 🙂
I was able to start airprint on my Canon MF3110 with raspbery pi (the challenge was to get the drivers) The advantage – the CUPS version is 1.7 already there. And now trying to do the same the same with my Asus 500 GP and Openwrt 12.09 r36088
I removed p910nd and the kmod file that is used with it. Installed CUPS (1.4 here) and had no success with finding new printer in GUI. When I try
The system freezes at this lines and then gives nothing more than:
I understand the Idea to reinstall from scratch, nut I got lots of thing runing on the machine. Could you please give me an idea?
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0424:2502 Standard Microsystems Corp.
Bus 001 Device 003: ID 0204:6025 Chipsbank Microelectronics Co., Ltd CBM2080 Flash drive controller
Bus 001 Device 004: ID 04a9:2660 Canon, Inc. MF3110
Thank you for the paper you made and hope you could help!
I have to admit, it’s been a couple years since I last looked at OpenWRT stuff, in which case I’d suggest making a post on the OpenWRT forums also.
Anyway, some suggestions:
– Reread all the steps up until “root@OpenWrt:/# /usr/lib/cups/backend/usb”.
I say this, because there is a lot there in the guide, and it could just be one little step missing which is causing the printer not to be observed by CUPs.
You could try “lsmod /usr/lib/cups/backend/usb” just to confirm the file *does* have the right permissions.
Also check the processes running on the system, just to make sure that there isn’t something from the previous p910nd installation causing issues.
I assume at some point during all of this, you’ve also rebooted your Router.
Make sure you’ve got all the right modules/sevices installed also, like hotplug etc..
As one side suggestion – If possible, try another printer. See if another one is detected, just to confirm whether there may be issues with it detecting your printer.
Sorry I can’t be more helpful.
I can’t even get past the first step. When I attempt opkg update opkg install cups, I get ‘unknown package ‘cups”.
Can’t find anything on this problem.
That is because you probably use 15.xx version. There is no package cups. Try with the 14.04? Please post if you could get it working with airprint here for 14.04
If not-let’s compile it from source?
By the way. there was a problem with openwrt server and to work on 14.04 you will need to change the opkg.conf file (see the oficial forum) i think that they will solve the problem soon.
Brilliant! Thanks so much, worked perfectly for our Canon Pixma MG2400 on OpenWrt Barrier Breaker 14.07
My only smallobservation, for us lazy types, is that in one section of your instructions you say:”To do this, enter: chmod 700 /usr/lib/cups/backend/usb.” – anyone copying and pasting that may also copy the full stop (period) at the end of that line after “usb”. 😉
Excellent tutorial though, thanks again.
Glad you got it to work, and this guide is still working! 🙂
and nice observation (although I’m sure it came out of “why isn’t this working??”) regarding the full stop. Have removed it…
Thanks it worked great on GL.iNet travel routers which run a version of openwrt. I not sure which part fixed my issue. It was showing me the printer when I used /usr/lib/cups/backend/usb but it wouldn’t show up in the web interface but it works now.
Yeah I remember when I initially set this up years ago I had a number of issues getting it to show up in the web interface. It was possibly permissions related at the time.
Thanks for the feedback! 🙂
i followed your tutorial. My printer is Canon LPB 2900 and it is sucessfully detected in CUPs page and i added the printer. when i try to give the print from Windows 7 pc it says” Print server error” Print server down. Please help me sir.
Some notes that helped me to make it working on asuswrt router.
If you have an old printer then you’ll have a hard time while searching for drivers to print directly from a router. I have found a working driver for my Xerox Phaser 3117 in splix package, and i ended up with this command:
opkg install cups cups-filters splix gutenprint
One problem that i haven’t solved yet is printing using android phone. Cups clients on android doesnt work with any of predefined printers on router: with driver or raw.