Centralized Printing Using CUPS
April 7th, 2004 by Colin Topliss in
Love or hate it, printing is something every user needs to do. In today's heterogeneous computing environment, providing a centralized printing solution can prove to be a pain. The days of having a large, dedicated printer for only UNIX systems are pretty much gone. I still remember the days of de-batching prints and sending them to users. Increasingly, system administrators find themselves having to make their UNIX systems print to printers sitting next to desks that are scattered throughout the company. Add to that the need for increased security, and you could find that firewalls also need to be navigated.
Such a situation exists where I work. A number of printers are scattered throughout the company, with UNIX systems sitting on different LANs and firewalls in between. None of the systems can talk directly to the LAN to which the printers are connected.
The CUPS server sits on a Linux system in a DMZ. This DMZ exists between the LAN where the printers reside and the LAN where the production systems lie. Installing CUPS on Linux was, as we all have come to expect, pretty painless. Add the RPMs, and the software is there and ready for use.
The configuration of the CUPS server also was quite straightforward. All of the configuration files reside in /etc/cups. Therefore, it was a simple case of modifying the cupsd.conf file to accommodate the environment. The only hiccup I experienced came when it was time to specify the listen IP address. Adding listen 127.0.0.1:631 to the cupsd.conf allowed the local host to be able to access the printers, but not the remote hosts. Changing this to the IP of the CUPS server itself allowed remote hosts to access the printers, but not the CUPS server. I needed both to appear for everything to work normally:
listen 127.0.0.1:631 listen 10.42.13.51:631
Remote management is extremely important. As the management has to be done from the same LAN as the printers, port 631 (the default port) had to be enabled through the firewall. This allows HTTP access to the administration facilities, which makes life a lot easier when it comes to defining and administering printers.
The other port to look out for is 515, the printer port. This must be allowed from the CUPS server to the Windows print server, if you have one, or to the network your printers reside on if you are defining network printers directly.
Printers can be added in a couple of ways. Both rely on knowing or being able to find out which printers are available to be used. In this scenario, the printers are networked printers being served by Windows servers. This is actually quite useful, as it does away with the need to find printer drivers for Linux. Like it or not, printer drivers usually are available under Windows before Linux, and in this instance the printer infrastructure already is present. The other bonus is we don't need to punch holes in the DMZ to allow the print server to talk to all of the printers in the network; fewer holes to the print server on the corporate LAN are required.
Printers can be added by using a Web interface or by manually editing the printers.conf file and creating the relevant .ppd file. This is great if you have an example to copy; otherwise, it is easier to add the printer using the Web interface.
An example printer entry in the printers.conf file, served from a Windows server (pserver) follows:
<DefaultPrinter p1_hp8150_01> Info 1st Floor Printer (BW) Location IRELAND DeviceURI lpd://pserver/p1_hp8150_01 State Idle Accepting Yes JobSheets none none QuotaPeriod 0 PageLimit 0 KLimit 0 </Printer>
The corresponding .ppd file can be found in the /etc/cups/ppd directory. The content of this file depends entirely on the type of printer. Michael R. Sweet's book on CUPS (ISBN 0-672-32196-3) covers writing .ppd files from scratch if required.
One of the major headaches I had was getting CUPS to compile under HP-UX11i. This is the nightmare situation that all system administrators hate the most--something doesn't work and you don't quite know who to turn to for help. HP was unable to help, and searches on the Internet at the time came up empty.
It's difficult to know quite what approach to take in this scenario. Problems like this one could be due to missing patches, broken patches, broken code or any other number of things. Therefore, the only option is to try to fix one thing at a time and see what happens.
The first thing I did was ensure I had the latest patches for HP-UX. There was no change, and the HP ANSI-C compiler still gave me problems. The next thing I tried was to use a GCC compiler. I had a slightly out-of-date version already installed, along with a slightly older version of binutils. A different error appeared this time, and it still failed to compile. Only by downloading the latest version of GCC and binutils, available from the HP-UX Porting Centre, could I finally get CUPS to compile. Even then it was not all good news. Although compilation worked, it now failed on the make install. This problem was as a result of using a bad option to the copy command, cp. I t turned out that the cp command included in HP-UX did not support the -d option. That option is available only to the GNU version of cp, which is part of fileutils. Even so, after having installed this, a problem still occurred when it came to completing the installation. Not being an expert in makefiles, I was beginning to run out of ideas.
While trawling back through the CUPS Web site looking for inspiration, I came across EPM. I decided that it would be worth a try, as it appeared to be able to create a software depot. Being an HP-UX administrator, I knew a bit about how this software worked. I knew that a depot consisted of files being taken from a source location and then being deployed to the final location, which was exactly what make install was failing to do. Thankfully, EPM built without any problems at all, and I was able to generate a depot. The final step in this phase involved installing the depot, and I finally found myself with CUPS installed in the right place.
I have to note that I did raise a bug report on www.cups.org but managed to resolve my problem in other ways. I was surprised to see that the bug report had been closed, with (as far as I can tell) no resolution to the original problem--the code refused to compile or complete the make install. Anyone trying to go though the same process likely will hit the same issues. At least there is a work-around, and it is included in the bug report.
The installation of CUPS on the desired HP server made no difference to the existing printing setup, partly because the application was calling custom code to print files as opposed to generating standard lp requests. This allowed CUPS to be installed and tested with no effect on the existing live service. This is something to bear in mind when looking to deploy CUPS in an environment where a live service may be affected.
As usual, the Linux clients were a dream. All that had to be done was to change the ServerName directive to the name of the CUPS server. In this case, only one server was effected. If you are considering multiple servers to be allocated on a per-user basis, it probably would be better to set the CUPS_SERVER environment variable to the name of the desired CUPS server.
Now, we can try to see if everything works by using lpstat. This command shows all printers available for use. The following example, issued from a system in the clean network to a CUPS server in a DMZ, shows a locally attached printer:
sys1:/opt # lpstat -t scheduler is running system default destination: lp0 device for lp0: parallel:/dev/lp0 lp0 accepting requests since Jan 01 00:00 printer lp0 is idle. enabled since Jan 01 00:00
This next example shows a number of remote printers. These printers are out on the network and are served by a Windows server:
monkey:~# lpstat -t scheduler is running system default destination: p1_hp8150_01 device for p1_hp8150_01: lpd://pserver:515/p1_hp8150_01 device for p1_hp8550_01: lpd://pserver:515/p1_hp8550_01 device for p2_hp4100_01: lpd://pserver:515/p2_hp4100_01 p1_hp8150_01 accepting requests since Jan 01 00:00 p1_hp8550_01 accepting requests since Jan 01 00:00 p2_hp4100_01 accepting requests since Jan 01 00:00 printer p1_hp8150_01 is idle. enabled since Jan 01 00:00 printer p1_hp8550_01 is idle. enabled since Jan 01 00:00 printer p2_hp4100_01 is idle. enabled since Jan 01 00:00
The printers now are defined, so it's time to try a test print:
sysl:/ # lp -d p1_hp8550_01 /etc/hosts
Your print job now should appear on the printer. Job done.
Subscribe now!
Breaking News
| "We'll Stop Fighting" Means Something Strange for Microsoft | 5 hours 12 min ago |
| AMD Calls Out Intel...We Think. | 3 days 6 hours ago |
| Bye-Bye TorrentSpy, So Long MPAA's Money | 3 days 8 hours ago |
| Sun Finds the Keys to Unlock MySQL | 5 days 2 hours ago |
Featured Video
Linux Journal Gadget Guy, Shawn Powers, takes us through installing Ubuntu on a machine running Windows with the Wubi installer.
Live From the Field
The latest posts from the Linux Journal team.
Delicious
Digg
Reddit
Newsvine
Technorati






Re: Centralized Printing Using CUPS
On May 11th, 2004 Anonymous says:
Hey,
I got it working, right?
This article was meant to show that we can get different UNIX environments working together. The solution uses CUPS throughtout up until the point we hand off to the Microsoft print server (so DUH - it is centralised printing using CUPS as far as all gathering all of the UNIX printing requirements).
I didn't say that creating ppd files by hand was the best way - I just said it could be done if necessary, and quoted the resource that tells you how to do it.
If I were to just write about getting CUPS to work under Linux, then it would have been a very short piece. I chose to show that, despite claims that the software should work out of the box, despite the problems I had getting the code to compile, someone CAN actually get this sort of stuff working.
So excuse me for trying to help other people realise that Linux, along with other flavours of UNIX (and even Windows) can be made to work together.
Re: Centralized Printing Using CUPS
On June 11th, 2004 Anonymous says:
I applaud Anon for the right to use the forum (HP, Linux whatever )as it was meant to be as I understand it, a help to others whatever their binary religion.
Also rightly the criticism that follows, free speech also lends a hand to lateral thinking and other ways to solve problems or forever be lounging in the criticism of Windows and still doing it!
I solved my problems using CUPS on Linux thru Windows clients rom forums like these.. I say 3 cheers! & thanks to the doers and critics as well.
Anon
Re: Centralized Printing Using CUPS
On May 10th, 2004 loven (not verified) says:
Hi Colin,
I am also tying to install CUPS on HP11.11. I have downloaded CUPS from http://hpux.connect.org.uk/ & all its dependancies. I swinstallED. It created /opt/cups. Where are the config files? what do I do next?
You discussion above is the only one I have found to be of any assistance. Can u help me further? I do not have your email, & this is a linux site. My email is ( delete the spaces ) is
isaac.loven @ ap. effem .com
THANKS.
Isaac
Re: Centralized Printing Using CUPS
On April 9th, 2004 rmstock (not verified) says:
This is the most awkward story sofar to run on the linuxjournal newssite yet. First off, the author chooses to fiddle around with HP-UX 11. Quite funny to see such articles when the website is called linuxjournal.com.
Next he starts rambling he needs to install and download all the latest gcc and gnu binutils. Again choosing HP-UX 11 doesn't help.
And then as someone else mentioned here, he starts editing some config files byhand, which is exactly _NOT_ the reason why someone would choose to run CUPS. Again shame on the author.
Administrating CUPS? openup http://127.0.0.1:631/ into your favorate browser of choice.
Robert
Re: Centralized Printing Using CUPS
On April 13th, 2004 Anonymous says:
Yes, it is a rather odd article for a Linux publication. Perhaps it should have a different title, because it's really about getting CUPS to work with HP-UX. Which is a good thing to write about, but 'Centralized Printing Using CUPS' is a bit misleading.
As far as CUPS' web interface goes, I don't care for it much. It's an easy way to install and change drivers, but I do all network and access settings in cupsd.conf. The web interface is completely inadequate for configuring the network and access stuff.
Carla
HP-UX
On April 11th, 2004 Anonymous says:
Personally, I like the fact that Linux can interoperate to some degree with original UNIXes, Windows, MacOS, etc. I'd rather see useful discussion of real-world environments than a "pure linux" focus. Few of us work in such an environment in the real world.
As for reasons to run CUPS, I /like/ the fact configs can be managed as text files. This gives more flexibility, and aids a clear understanding of exactly what's going on - vital when it comes time to fix a problem. It's nice to have other management interfaces, but the fact that they all back onto a text config is vital.
Personally, I don't like the web interface much. Additionally, it can't do most of the things he was editing config files to do - enable listening only to certain addresses, enable access from other hosts, set a different default server for clients, etc.
Additionally, I don't see how else you're supposed to switch clients to a different CUPS server in a distro-independent way. Setting the environment variable isn't a particularly attractive option for the global setup, when a one-line config tweak does the trick.
Craig Ringer
Re: Centralized Printing Using CUPS
On April 8th, 2004 Anonymous says:
I am interested in the comment in this article that "In this scenario, the printers are networked printers being served by Windows servers. This is actually quite useful, as it does away with the need to find printer drivers for Linux. Like it or not, printer drivers usually are available under Windows before Linux".
On my home network, I have a Canon MultiPass F30 (dating from 2002), also sold in other countries as a Canon ImageCLASS MPC400. The BrightQ products are for bigger iron than my SOHO multifunction printer with USB/parallel connectors but no network connector. The gurus of linuxprinting.org declared it to be a "paperweight" so far as Linux is concerned; I have therefore connected it locally to a Windows box. From Linux, I use KDEprint (configured to use CUPS and the linuxprinting.org Canon S630 driver) to send a printer stream through Ghostscript to the Windows computer.
The comment that "it does away with the need to find printer drivers for Linux" implies that my solution is unnecessarily complex. Have I missed a simpler solution which does not require the kludge of using the Linux driver of a different, albeit related, printer?
Re: Centralized Printing Using CUPS
On October 21st, 2004 Anonymous says:
Yah... it is the one of the problem using linux over the windows network..
Re: Centralized Printing Using CUPS
On April 8th, 2004 Anonymous says:
For those of you who have similar heterogeneous operating environments and
printing requirements in the work place, you should take a look at BrightQ
http://www.brightq.com. It automates many
of the processes that the author is referring to here. BrightQ supported Unix
and Linux and has been adopted by many of the "big iron", high-volume, networked
multi-function printers......
Canon - http://canon.codehost.com
Ricoh - http://ricoh.codehost.com
Lanier - http://lanier.codehost.com
Savin -
Re: Centralized Printing Using CUPS
On April 8th, 2004 Anonymous says:
All Kyocera printers understand Postscript and don't need special drivers. It is not necessary to register to any commercial solution.
Re: Centralized Printing Using CUPS
On April 8th, 2004 Anonymous says:
> Printers can be added by .... or by manually editing the printers.conf file
D'oh!
Nowhere -- I repeat: nowhere! -- in any of the official and semi-official docs about CUPS has this "manually edit the printers.conf file" ever been mentioned. It is a really dumb idea to suggest this, even if it works. It is dumb for 3 reasons:
-- it is too complicated.
-- it only adds "raw" printqueues (because it doesn't add the PPD file for non-raw printing).
-- It requires a re-start of cupsd. (And this is not even menitioned in this "great" article!)
To suggest that everyone writes his own PPD files is equally dumb, and unnecessary. There are many PPD files available which work flawlessly for CUPS:
* every PostScript printer ships with one (meant to be used with the Windows- or Mac OS-driver). They work perfectly with CUPS.
* there is the great repository on Linuxprinting.org of PPDs for more than 1000 non-PostScript printer models.
* there is "ESP Print Pro", a commercial product by the CUPS developers themselves shipping with 3000+ PPDs.
I tell you 3 other means to install a printer:
* Use the great KDE frontend, the "Add Printer Wizard": type [ALT]+[F2], and then "kaddprinterwizard" to start it.... It is self-expaining.
* Use the commandline:
lpadmin -p p1_hp8150_01 -D "1st Floor Printer (BW)" -L "IRELAND" -v lpd://pserver/p1_hp8150_01 -E -P /usr/share/cups/model/laserjet.ppd
The quoted command line will install exactly the printer with the comments you want much more quickly than the web interface. It will not require a re-start of CUPS. (It will give you even the option of non-raw printing, and printing with job-options like "duplex" or "A3" paper, even if the "laserjet.ppd" is not the optimal one for a HP 8850 PostScript printer!) Oh, and "lpadmin" is well documented in the man page! One could expect an experienced Unix admin to look in the man page, before trying to fiddle around on his own....
"HOWTO"s like this one may even confuse gurus like Eric Raymond! No wonder, he was choosing CUPS as his prime example (while there would have been many better ones to proof his points, including "fetchmailconf"... ;-)
Please research your topic more profoundly before you publish it. Reading it reminded my of the guy who tried to reverse-engineer how the great new Open Source "X Compression" libraries from NoMachine work, instead of asking on the mailing list, or reading the source code, or even looking at the available documentation!
This article shouldn't be reconmended by anyone for reading.
Cheers,
Kurt Pfeifle
(Author of many print-related documents, Co-Maintainer of Linuxprinting.org)
Re: Centralized Printing Using CUPS
On April 8th, 2004 Anonymous says:
A big problem linux has with printing is that it struggles to let the users print their output in user selected resolutions. E.g. low quality but fast for drafts and high quality for final output. This has been available in windows for many years, and yet for some reason linux (and probably other *nix) is still stuck filtering postscript methods.
Re: Centralized Printing Using CUPS
On April 8th, 2004 Anonymous says:
Don't know what you are talking about. Clicking on the advanced setting lets me change resolutions easy. And unlike winblows I don't have to reconfigure my printers every couple of months because the drivers get corrupted or the OS loses track of were the printer is.
Of course changing CUPS printers can be dependent on how your window manager hadles it, but KDE 3.2 (and 3.1) does an excellent job.
Re: Centralized Printing Using CUPS
On April 9th, 2004 Anonymous says:
Talking you about user print window or line parameter OR about printers settings. (yes I can define eight diferent spool for eight setings to workaroud this problem and go to Hell with four printers with multiple parameters)