Ferdinand Keil's

electronic notes

Jan 15, 2017

Setting up CUPS with LPR on Raspbian

With CUPS you can easily set up a Raspberry Pi as print-server. Out of the box client can connect to CUPS over IPP (Wiki - Internet Printing Protocol). However, on Windows machines this have unwanted side-effects whenever the server is turned off: everytime I opened a document in LibreOffice the program froze for more than a minute. This is due to the Windows Spooler searching for the print-server until a time-out occurs. This behavior can be avoided by using the LPR protocol (Wiki - Line Printer Daemon protocol). In the following I will describe the necessary steps for this setup.

I tried this on a Raspberry Pi 1 running Raspbian Jessie Lite (2016-11-25).

Step 1

First you'll have to install CUPS. For LPR to work you'll also need xinetd. And I also needed splix as it contains the driver for my printer (Samsung ML-2010PR).

sudo apt-get install -y splix cups xinetd
sudo cupsctl --share-printers --remote-admin
sudo usermod -a -G lpadmin pi

The second commands enables printer-sharing and the CUPS web-interface. The last command allows the user pi to change the settings for CUPS.

Step 2

To enable LPR you'll have to configure xinetd. Create a new config file named cups-lpd in /etc/xinetd.d:

sudo nano /etc/xinetd.d/cups-lpd

Paste the following configuration into the file:

service printer
{
    socket_type = stream
    protocol = tcp
    wait = no
    user = lp
    server = /usr/lib/cups/daemon/cups-lpd
    server_args = -o document-format=application/octet-stream -o job-sheets=none,none
    disable = no
}

Then restart xinetd:

sudo /etc/init.d/xinetd restart

Step 3 and Finish

Now add your printer through the CUPS web-interface. It can by found at https://YOUR-IP:631/admin and use the credentials for the standard user pi. Make sure you enable network sharing. Then you can add the printer on the clients. For Windows you have to add a Generic Network Interface. Make sure to set the queue name to the one you chose in the web-interface. Also, you have to enable LPR Byte Counting or it will not work!