Categories
Computers

How To Setup Printing to a Remote CUPS Server

UPDATE 5/10/2012: A further server side configuration detail is to make sure the printer in question is shared. This setting can be accessed during the printer modification dialog.

I’ll spare the blow-by-blow and just get right to the requirements. Suffice it to say that I spent way too much time figuring this stuff out. However, throwing it out there may spare someone else the frustration of banging their head against this stuff. As I’ve observed before- Linux printing sucks.

My network situation is pretty straight forward: I have a “primary” wired ethernet network and a “secondary” wireless network. I use the scare quotes because by “primary” I’m referring to the fact that the ethernet is connected to the cable modem in the basement and thus provided internet connectivity; while by “secondary” I’m referring to the wireless network’s connection to the wired network using a wireless router. My IP ranges are straightforward: 192.168.1/24 for the wired and 192.168.2/24 for the wireless.

I’m describing this setup because it creates a critical problem for CUPS printing: the wireless network cannot automagically discover printers on the wired network. So most of the howto’s out there were useless for me. I had to piece things together. In particular, I’d like to point out the Gentoo printing guide as being particularly useful for solving a couple of my headaches.

My printer is an HP D1420 Deskjet printer connected to a USB port on the server. The first steps are to make the printer visible to the network and to enable IPP. So, to start, we need to make some modifications to cupsd.conf on the server. As of the writing of this post, the cups version on both machines is 1.4.6.

To start, add the following 2 lines:

ServerName hostname.domain
ServerAlias *

I added these lines to prevent a certain class of gotchas related to hostname lookups. Next, if there are any Listen lines in the file comment them out (except the one listening for cups.sock) and add the following: Port 631

The Port directive is equivalent to Listen *:631.

Now, allow access to the server from the networks. There are a series of <Location>...</Location> stanzas that control access to the print server filesystem. By default, they are locked down to the local machine. I sprinkled the following 2 lines inside each of these stanzas:

Allow from 192.168.1.*
Allow from 192.168.2.*

These allow for server access from my networks. If uninterested in viewing admin pages and the like, then just add them to the stanza that affects general server access. It’s the one that starts with the <Location /> tag.

That’s the server setup. Restart cups using something like /etc/init.d/cups restart. Now, time to setup CUPS on the remote computer- from here I’ll refer to it as ‘laptop.’ In general, it’s like setting up a CUPS server. I used aptitude to install cups and cups-client. The latter package will make verifying connection to the server easier.

After installing cups, start by editing the file /etc/cups/client.conf and adding a line like the following:

ServerName server_ip:631

I specified the IP address directly, but the hostname of the server is also valid. After doing this, commands such as lpstat -a or lpstat -t should return information about the printer on the server. Make sure to run them as root. If they don’t, then check the server configuration- the printer still isn’t accessible from the network.

Next, go to the web interface at localhost:631 on the laptop and under the Administration tab select Add a Printer. At the first prompt, select an Internet Printing Protocol(ipp) printer and then continue. The prompt is for the connection URI. The format of the connection is something along the following lines:

ipp://'server_ip':631/printers/'queue'

The server_ip setting can also be the hostname and should be pretty straightforward. The queue setting is the name of the printer queue on the server. In my case, the name is D1420, so my full URI ended up like:

ipp://192.168.1.1:631/printers/D1420

After entering the URI, proceed through the human readable stuff like name and location. After that, the setup will prompt for the printer type and here is the second key setting. Do NOT select the actual printer type. Instead, select a raw printer. The raw type is used because the cups server is already configured to process file information. In order to take advantage of it, the laptop just needs to send the raw file data and let the server handle filtering and rasterizing and all the other stuff. If the laptop were to rather process the file and send the actual printer data to the server, the server would end up choking on the data and cause an error.

Finish the setup from there and everything should be good to go. There is no need to modify the /etc/cups/cups.conf file on the laptop. At least, I didn’t have to modify mine. It should be possible to send a test page to the server now.

I’ll also note that, once the printer is propery configured, accessing it through the web interface will actually link to the server. To see what I’m talking about, press the Printers tab and then hover over the printer just added. The link will point to the server rather than the localhost. It’s important to realize this since attempts at certain controls may result in some kind of seemingly mysterious authorization error. The error results because the user on the laptop likely isn’t authroized to perform those operation on the server. The printer can still be accessed locally on the laptop by typing the URL into the browser like so:

http://localhost:631/printers/D1420

This address will only affect the local queue on the laptop, though.

Happy printing!

2 replies on “How To Setup Printing to a Remote CUPS Server”

I always wondered why the laptop would NOT work with the printer … now I know … wireless tomfoolery !!
Be prepared to address this issue on your next visit !!!

Hi, Gerry
my name is Victor, I’ve been thinking of a little project with printers and I don’t know how to start. I ran into your blog and thought maybe you would be able to help me.
I want to print to a remote pos (restaurant printer) remotely with the least amount of setup on the other end. basically I want to send the printer have them connect it to the power and to a router (internet) and be able to print to it. is this too much to ask? so far I’ve looked into 3 possible solutions, a print server (linux with CUPS on a plug computer), google cloud printing (needs a full sized computer running 24/7), or some sort of VPN solution.
If you have any Ideas please let me know
Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *