Raspberry pi as a print server: How to Make a Raspberry Pi-Powered Print Server

Setup a Print Server using Raspberry Pi & CUPS: Part 2 | by Anirudh Gupta

6 min read

·

Jun 22, 2019

This is the continuation of the Part 1 of the article, where we covered the initial setup of our Raspberry Pi. If you have not setup your Pi, I recommend you to follow Part 1.

In this part, we will setup our printer server software CUPS on the Pi. A computer (Raspberry Pi) running CUPS is able to accept jobs from client devices, process them and pass it on to the appropriate printer to print.

Open a new terminal window (or ssh) on your Pi and follow.

1. Update Pi

We need to be sure that our Pi runs the latest software.

sudo apt-get update
sudo apt-get upgrade

With this done, reboot the Pi.

sudo reboot

2. Use Static IP

We need to make a few system tweaks so that we can use the Pi as a “server” on the network. We need to set the DHCP client to use a static IP address; by default, the DHCP client might pick any available network address, which would make it tricky to know how to connect to the Raspberry Pi over the network.

We start by editing the DHCP config file

sudo nano /etc/dhcpcd.conf

Scroll to the bottom of the file and add one, or both of the following snippets, depending on whether you want to set a static IP address for a wired connection (eth0) or a wireless connection (wlan0).

interface eth0

static ip_address=192.168.0.10/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

interface wlan0

static ip_address=192.168.0.190/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

  1. interface: Network interface you are setting the configuration for.
  2. static ip_address: This is the IP address that you want to set your device to. (Make sure you leave the /24 at the end)
  3. static routers: This is the IP address of your gateway (probably the IP address or your router)
  4. static domain_name_servers: This is the IP address of your DNS (probably the IP address of your router). You can add multiple IP addresses here separated with a single space.

Save the file using Ctrl + X then press Y followed by Enter.

Finally, reboot your Pi.

Note: You may have a different network configuration where address class and IP address may differ. Perform this step carefully, else the Pi can suffer connectivity issues. To get an idea of what ip address you must use, run and observe inet and netmask values:

ifconfig -a

3. Install CUPS

Next, we need to install CUPS. This will take some time but will install CUPS and other dependencies like samba, perl and several other software or libraries.

sudo apt-get install cups

4. Configure CUPS

We need to make some changes to the configuration file of CUPs. The config file can be edited using:

sudo nano /etc/cups/cupsd. conf

Change/add the following lines to the configuration file. These changes will allow us to interact with CUPS panels.

# listen on all interfaces
#Listen localhost:631# Restrict access to the server...
<Location />
Order allow,deny
Allow @Local

</Location>

# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow @Local

</Location>

# Restrict access to configuration files...
<Location /admin/conf>
AuthType Default
Require user @SYSTEM
Order allow,deny
Allow @Local

</Location>

If you want to change the port (CUPS operate on port 631 by default), find this line and change it.

Port 631

Further, if you want to access CUPS Web Interface from a domain, you need to allow requests from those domains. Add the following lines before <location> tags.

# You can allow all domains to access the interface
ServerAlias *
# or provide a specific name.
# ServerAlias one.example.com two.example.com

Save the file using Ctrl + X then press Y followed by Enter.

5. User & Network Access Settings

Next we add the Pi user to the lpadmin group. This gives the Raspberry Pi the ability to perform administrative functions of CUPS without necessarily being a super user.

sudo usermod -a -G lpadmin pi

We need to ensure that CUPS is accessible across entire network.

sudo cupsctl --remote-any

Finally, restart CUPS to effect changes

sudo /etc/init.d/cups restart

6. Setup Samba

Samba is the standard Windows interoperability suite of programs for Linux and Unix. It will allow Windows system to communicate with our CUPS server running on the Pi, and will allow us to send print commands from Windows.

sudo apt-get install samba

We need to edit its configuration:

sudo nano /etc/samba/smb.conf

Scroll to print section, change guest ok = no to guest ok = yes

guest ok = yes

Scroll to printer driver section, change read only = yes to read only = no

read only = no

Save the file using Ctrl + X then press Y followed by Enter.

Finally, restart samba to effect the changes:

sudo /etc/init.d/smbd restart

7. Printer Setup

7.1 Installing Printer Drivers

You may need to install drivers for your printers. You can trying skipping this step (7.1) and proceed to next step. If next step fails, then you need to figure out “How to install drivers for <insert printer model> on Debian Raspberry Pi OS”. You can google it.

I know the process for HP printers, run:

sudo apt-get install hplip

Optionally, also install GUI:

sudo apt-get install hplip-gui

Then run (select USB if printer is USB based, and select Download plug-in from HP when prompted):

hp-setup -i

7.2 Adding Printer to CUPS

This is the last and most easiest step to do. From your PC, connect to the same network as your Pi. Open a web browser and go to the CUPS homepage by entering your Pi’s IP address followed by “:631” which is port address on which CUPS is communicating. It may be different in case you changed the port. The browser may show a warning “Connection not secure”, click “Proceed Anyway”.

To know your Pi’s IP address, you can run the command hostname -I from your Pi. In my case, the web address is:

192.168.0.190:631

Go to Administration page and click Add Printer. Make sure that your printer is switch on and connected to your Pi via USB. Follow the prompts and setup the printer. Before the final step, ensure that you check the “share this printer” checkbox. Finally, you can print a test page on Printers page to verify if everything works.

Note: Your printer may not be listed in “Local Printers” on the Add Printer page. If that is the case, you need to install the required printer drivers on your Pi. Search the Internet for a way to install your printer drivers on Linux. In my case (HP Printers), I had to install hplip from here or from above step. The latest version didn’t compile on my Pi (It didn’t support latest Raspbi OS at that time). I had to use version 3.18.6 with custom setup and uncheck Qt4 & Qt5 interfaces.

This completes our CUPS setup. The final task is to send print commands using the connected devices. After this, you will be able to print using Linux, Windows, Mac, Android and iOS wirelessly. We need not install any printer drivers for that. Continue to the last part, where we finally print wirelessly.

PS: After adding a printer, there was a problem occurred. For some reason, the printer would only print first few X jobs, and ignore the remaining jobs. To continue printing, I had to either restart my Pi, or restart my printer. The following command fixed my problem:

# Replace PRINTERNAME with the name used in step 7. Eg: m1136
lpadmin -p PRINTERNAME -o usb-no-reattach-default=true# Restart your Pi
sudo reboot

How to Make a Raspberry Pi Print Server

Most people can get by with an outdated laser or inkjet printer, but using it might be a pain in the posterior if yours lacks Wi-Fi. Yet it’s simple enough to turn a Raspberry Pi into a wireless print server, letting you use any networked computer to print to your wired printer. Here’s how to make a Raspberry Pi print server.

What You Need to Make a Raspberry Pi Print Server

The equipment required for this Raspberry Pi print server tutorial is listed below.

Recommended

Optional

  • Raspberry Pi Case
  • USB Keyboard
  • USB Mouse

How to Set Up a Raspberry Pi Print Server

  1. On the Raspberry Pi, launch a terminal window or login via SSH.
  2. Update the list of installable software.
sudo apt update
  1. Install the Common Unix Print System (CUPS) software.
sudo apt install cups
  1. Add the default user, pi, to the group of users who can use printers.
sudo usermod -a -G lpadmin pi
  1. Create a static IP address so that the Pi can always be located on the network. 
sudo nano /etc/dhcpcd.conf
  1. Add a static IP address and details of the router and DNS server to the bottom of the file. Depending on how your router is set up, these details may change. To save and quit, press CTRL + X, Y, and Enter after finishing.
interface wlan0
static ip_address=192.168.0.99/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
  1. Configure CUPS so that it is accessible across the network.
sudo cupsctl --remote-any
  1. Setup SSH remote access to the Pi if it’s not already setup. Launching raspi-config (sudo raspi-config), enabling SSH under Interface Options->SSH, quitting, and restarting are the steps needed to do this.
  1. Navigate to the Raspberry Pi’s IP Address, followed by: 631, on another computer’s browser. In our example, the IP address is 192.168.0.99.
192.168.0.99:631

Read More: How to Turn your Raspberry Pi into a Web Server

You’ll see the CUPS web interface, from which we may administer the printer server.

  1. Click on the Administration tab, and on the next screen, click Add Printer.
  1. Upgrade your CUPs if you get an “Upgrade Required” warning, followed by a link to download.
  1. Select Advanced and then Proceed if you receive a “Your connection is not private” warning.
  1. Enter your username and password; by default, these are PI and raspberry.
  1. Click on the radio button next to the name of your printer.
  1. Select the model of your printer, and then click Add Printer. Typically, the first value returned should be correct.
  1. Check the configuration of the printer before clicking on “Set Default Options“.

Read More: How to Run Google Stadia on a Raspberry Pi

  1. Go to Printers and then click on your printer. To open the configuration screen for that printer.
  1. Click on Print Test Page, found in the Maintenance menu, to print a test page and confirm that our printer is working properly.

Using the Raspberry Pi Print Server from a Windows device

Installing the printer on Windows 10 is a breeze. Simply make sure your Windows device is on the same network as the print server.

  1. From the Start Menu, search for printers and click on Printers & scanners.
  2. Click on Add a printer or scanner
  1. Click on the print server.
  1. Click on Add Device, and Windows will communicate with the print server.
  1. Click on Manage to open the printer settings page.
  1. Click on Print Test Page to test that Windows can successfully use the print server.

Conclusion

I hope that this tutorial has shown you how to set up a Raspberry Pi print server and that you haven’t run into any issues.

If you have any feedback, tips, or issues to offer, please leave a comment below.

Oh hi there It’s nice to meet you.

Sign up to receive awesome content in your inbox, every month.

We don’t spam! Read our privacy policy for more info.

Email Address *

# DIY# How to# Print Server# Raspberry Pi

Print server on RaspberryPI 1 / Sudo Null IT News

We assume that we have a set of RPI, flash drive with Raspbian, Wi-Fi adapter, HP LaserJet Pro 1102 printer, HP Deskjet F2180 MFP and usb hub. The main machine (BB) that will use the print server lives on Linux (however, the differences in use for Windows will be minimal).

Preparation

In order not to connect to the RPI by wire, let’s add auto-connection via wi-fi. To do this, insert a flash drive with Raspbian into the BB and go to /boot, where we will create 2 files:

Insert a flash drive into the RPI, a wi-fi adapter (directly, not into the hub — it is for printers), connect the power. In a minute, we climb onto the wi-fi router to find out the address that it issued RPI, and go to it via SSH.

Run RPI configuration by running raspi-config .

If you are not satisfied with addressing by IP, you can set the hostname to work through mDNS. We write the name at /etc/hostname and in /etc/hosts for example, printserver.local, commit the changes sudo /etc/init.d/hostname.sh and go to reboot. After a reboot, RPI via mDNS will be available at printserver.local. For Linux, mDNS works by default, and for Windows, you need to install the Bonjour print service.

Install CUPS

First run

 sudo apt-get update && sudo apt-get upgrade 

Then install CUPS

 sudo apt-get install cups 

To be able to manage printers in CUPS, you need to add some user to the lpadmin group. We proceed from the fact that we are working under the default user — pi. Let’s add it here:

 sudo usermod -a -G lpadmin pi 

sudo /etc/init.d/cups restart

In principle, we have a ready-made CUPS, which is available at https://printserver.local:631/ and, probably, for many printers it will work like that, but not in our case.

Printer HP LaserJet Pro 1102

No suitable drivers were found in the standard package for this beast. I had to install the driver from foomatic:

 sudo apt-get install printer-driver-foo2zjs-common printer-driver-foo2zjs 

and select another driver for this printer in the admin: HP LaserJet 1022 Foomatic/foo2zjs-z1

9000 2 He started typing, but is very slow and sometimes stupidly misses my commands.

I left the configuration with this driver because it allows you to print from any device without installing drivers, albeit long and mostly one page. For larger volumes, I had to set up a different configuration of the same printer in CUPS.

We will use xinetd to emulate an HP-jetdirect printer. First install xinetd:

 sudo apt-get install xinetd 

Now configure our service for xinetd:

 service hp-jetdirect
{
       socket_type = stream
       protocol=tcp
       wait = no
       user = pi #our user is here
       server=/usr/bin/lp
       server_args = -d HP_LaserJet_Professional_P1102_direct -o raw
       groups = yes
       disable=no
} 

HP_LaserJet_Professional_P1102_direct — what the jet-direct printer profile will be called in CUPS.
Run:

 /etc/rc.d/xinetd start 

Now go to the admin panel and create a new printer named HP_LaserJet_Professional_P1102_direct. The main thing is to choose this driver: Local Raw Printer. As a result, our printer will have a network link https://printserver.local:631/printers/HP_LaserJet_Professional_P1102_direct, which must be used when setting up printing on the WB.

That’s it, now the main thing is to install the driver on the machine from which we print and voila — large volumes are printed at normal speed.

Scanner HP Deskjet F2180

Actually, this is not a scanner, but an MFP, but I only use it as a scanner.
To scan, we need sane

 sudo apt-get install sane 

Then we use a utility that allows us to see what we have for scanners

 sudo sane-find-scanner 

In the case of the HP Deskjet F2180, you most likely will not see a scanner.
Install drivers from hp:

 sudo apt-get install hplip 

Now repeat the search:

 found USB scanner (vendor=0x0424, product=0xec00) at libusb:001:003 

Ok, now let’s see if our scanner can accept commands

 pi@PrintServer:~ $ sudo scanimage -L
device `hpaio:/usb/Deskjet_F2100_series?serial=CN78R4R3PB04TK' is a Hewlett-Packard Deskjet_F2100_series all-in-one 

i.e. the scanner works on RPI.

Next, on the remote linux , install sane and sane-utils and climb into /etc/sane.d/net.conf to add the RPI address

at the very bottom Unfortunately, on the remote machine sudo scanimage -L issued.

 No scanners were identified. If you were expecting something different, check that the scanner is plugged in, turned on and detected by the sane-find-scanner tool (if appropriate). Please read the documentation which came with this software (README, FAQ, manpages). 

Having scanned the ports, RPI saw that port 6566 was closed. Well, let’s configure xinetd 9 a little more0003

 sudo nano /etc/xinetd.d/sane-port 

Insert

 service sane-port
{
       socket_type = stream
       port=6566
       wait = no
       user = root
       group = root
       server=/usr/sbin/saned
       disable=no
} 

Exit, save and restart the service:

 sudo service xinetd restart 

Repeat on the remote machine sudo scanimage -L and see

 device `net:printserver.local:hpaio:/usb/Desk jet_F2100_series?serial=CN78R4R3PB04TK' is a Hewlett-Packard Deskjet_F2100_series all-in-one 

Just what you need. You can start scanning by running xsane.

Thank you for your attention.

upd praeivis xsane available under Windows

Used

https://samhobbs.co.uk/2014/07/raspberry-pi-print-scanner-server
https://blog.johanv.org/posts/old/node-195.html
http://lib.ru/unixhelp/linuxset.txt

Raspberry Pi print server with AirPrint support. Blog Ampercot.ru

March 09, 2015

Thinking about buying a new printer that supports network printing, but is it a pity to throw away the old one?

If you have a Raspberry Pi handy, you can breathe new life into an old thing and set up your own print server with AirPrint technology.

To implement our idea, we will use CUPS

CUPS is a print server for UNIX-like operating systems. The computer running the CUPS server is a network node that accepts print jobs from clients, processes them, and sends them to the appropriate printer.

Connect to the Raspberry Pi console using a mouse, keyboard and monitor, or via ssh.

Raspbian Wheezy already has the corresponding packages in the repository, so nothing needs to be compiled further.

Installing

Let’s install CUPS on our system:

 sudo apt-get install cups 

The installation process can take a long time, so be patient.

Configuration

After the installation process is complete, we must define the users who can access printer management through CUPS. If you have a standard Raspbian system and a standard user named «pi», then run the following command:

 sudo usermod -a -G lpadmin pi 

This command will add user pi to the lpadmin group. This group is created by CUPS so that the system can know which users have access to configure printers.

CUPS gives you access to manage printers and jobs right from your browser.

By default, CUPS settings allow connection to the web interface only from the localhost host. If you are doing all the steps by connecting directly to the Raspberry via a mouse, keyboard and monitor, then it will be enough to open the address in the browser:

 http://localhost:631 

and the interface will open.

But most often it happens that access to the administration is required from the outside and the standard settings will not allow you to connect to the web interface from another computer. Let’s fix this annoying fact.

Shortcut

Run the command in the console

 sudo cupsctl --remote-admin 

This command will completely rewrite the CUPS configuration file so that it can be accessed from outside.

Don’t forget to restart the CUPS server

 sudo service cups restart 

Now open on any computer on the same network as Raspberry, address:

 http://:631/ 

microcomputer. You can find out this address with the ifconfig command in the console.

Long track

The short track is good for a quick start, but it has its drawbacks. For example, any computer on the network will be able to access the interface. However, it should be noted that the most important parts of the CUPS interface are still protected by the username and password of the pi user (remember that we added him to the lpadmin group?), So this option for home use may be enough. But if you intend to use the print server in the office, then it would be better to read the CUPS configuration guide on the official website in order to configure it in the most secure way.

The configuration file itself is located here:

 /etc/cups/cupsd.conf 

Configuring printers

So, we got access to the administration, now we need to configure the printer itself. Don’t forget to connect the printer to the Raspberry’s USB input and power it up.

Go to the Administration tab and click the Add Printer button

When you go to the page for adding a printer, you will be asked for a login and password. Enter pi as login, enter pi user password as password. If you haven’t changed your password, then enter raspberry. You should also be warned that printers are configured only through an encrypted SSL connection, so the browser will redirect you to the https page instead of http. However, some browsers may warn you that this encrypted connection is not secure.