Cups - network client access

Dec 18, 2012 Networking System

I used to think that network printing under Linux was difficult when connecting to a remote printer server, however it’s actually not at all difficult… if you know how.

Server setup

I presume you already have a working version of cups installed on one of the network PC’s, with access of course to a printer. If not, then please do before continuing, as this method requires a dedicated printer server/pc which will always have to be on when printing from another computer in the network.

On Gentoo Linux the cups server will by default deny network access. To change this you have to edit the cups config file (/etc/cups/cupsd.conf). There is a section which looks like a standard apache config:

<Location />
 Order Deny,Allow
 Deny From All
 Allow From 127.0.0.1
</Location>

Here you should add the IP(ranges) of the computer(s) that need to connect. My laptop for instance has the internal IP of 192.168.0.3. You should add it to that section of the config, leaving you with something like:

<Location />
 Order Deny,Allow
 Deny From All
 Allow From 127.0.0.1
 Allow From 192.168.0.3
</Location>

Now restart the cupd server

/etc/init.d/cupsd restart

Client setup

As we are using cups, you will have to install the cups client. On Gentoo this means actually installing the cups server as well, however even though it’s installed we do not actually need use the server. It is the client we need. When cups is installed it by default becomes the default printing service so your Linux should be OK to use it ~ if not you will have the check the docs for your distro.

Now we need to set up the client config for the network printers. In /etc/cups/client.conf we see the line:

You need to change this to the IP/hostname of your cups server and un-comment it. So, in my case I’m left with:

ServerName workstation

Testing

Now to test to see if we have communication, we use the tool called lpstat:

lpstat -p
printer hp2100 is idle. enabled since Jan 01 00:00
printer hp4200 is idle. enabled since Jan 01 00:00
  Ready to print.

This should return the exact same printers that were configured on your cups server. The printers (defined here by the names “hp2100” and “hp4200”) can now be accessed “locally” on the clients defining which printer to use with:

lpr -P <printername>

This will of course use the default settings configured on the printer server for each printer. If you require other options (resolution, paper type etc) then refer to the man pages of lpd/lp for more information.

Comments