28-mar-2016: Welcome to our new server! Faster and less prone to crashing.

Welcome to the Slackware Documentation Project

Desktop printer sharing with CUPS

Using CUPS, a USB printer can be network shared by the system it is connected to. While full printer discovery requires avahi, it is possible to set up simple printer sharing on Slackware 14.2 without installing any new software. In this case, the server is the machine that the printer is connected to via USB, whereas the client is any networked machine that wants to print. Obviously all machines need to be on the LAN, and direct printing over USB should already be working on the server.

Server configuration

CUPS needs to be enabled, so;

chmod +x /etc/rc.d/rc.cups

The CUPS daemon will then start on boot, and it can be restarted for testing purposes by issuing;

/etc/rc.d/rc.cups restart

You should be able to access the CUPS interface in your web browser at http://localhost:631/

If you are using AlienBob's firewall config you will want to add these two firewall rules (modifying the x's as appropriate for your LAN);

$IPT -A udp_inbound -p UDP -s x.x.x.0/24 --destination-port 631 -j ACCEPT
$IPT -A tcp_inbound -p TCP -s x.x.x.0/24 --destination-port 631 -j ACCEPT

The CUPS help tells you to enable sharing via;

cupsctl --share-printers

but be careful as this will clobber your /etc/cups/cupsd.conf

The simplest configuration requires that CUPS listen on the LAN (rather than just the default of localhost). Inside /etc/cups/cupsd.conf the minimum necessary changes to the Slack 14.2 default are;

#Listen localhost:631
Port 631

<Location/>       
  Order allow,deny
  Allow @LOCAL
</Location>

Your printer also needs to be set to shared. By default my HP LaserJet M402dn was shared, and you can check this in /etc/cups/printers.conf where there should be a line for your printer that says;

Shared Yes

printers.conf should not be edited while CUPS is running! You can stop it with;

/etc/rc.d/rc.cups stop

Sharing can also be enabled with the command;

lpadmin -p printer -o printer-is-shared=true

where 'printer' is the name of the CUPS printer (which can be found at CUPS printers). Note that this will not cause the printer to show as “Shared” on its CUPS page. E.g. my LaserJet says “HP_LaserJet_M402dn (Idle, Accepting Jobs, Not Shared, Server Default)”, however, this printer is in fact shared over the network. Adding the directive;

BrowseLocalProtocols dnssd

will cause the printer to show up as “Shared”, but I believe this is referring to printer browsing, and probably requires avahi. At any rate, it is not necessary for the simple sharing setup described in this guide.

Client configuration

Now that the server is configured, the client can be set up to print. I have only tested this on a Mac, which was as simple as opening the printer's IPP address in Safari (which then provides the option for adding the network printer). The printer's IPP address is nearly the same as the one found in CUPS (on the server). For example, on my CUPS server printer list, I have this link;

http://localhost:631/printers/HP_LaserJet_M402dn

For the IPP address, simply replace the protocol, hostname, and remove the port. E.g.;

ipp://darkstar/printers/HP_LaserJet_M402dn

or more generally

ipp://server_hostname/printers/cups_printer_name

I have no experience with configuring clients on other operating systems, so the addition of that information would be appreciated.

Troubleshooting

If you are having difficulty, you can check the CUPS error log at http://localhost:631/admin/log/error_log

Sources

* Originally written by drgibbon


In Other Languages
Translations of this page?:
QR Code
QR Code howtos:network_services:desktop_printer_sharing_cups (generated for current page)