Share a USB Printer connected to QNAP( 2023 version)


Previously, QNAP provided network printer sharing, which has since changed. The default print server function is gone, but there are still ways to share a USB printer. There are three current methods: running a VM with USB passthrough, deploying a print server via Container, or utilizing the paid VirtualHere USB Server. While VirtualHere is straightforward, it involves a fee. Running a VM is simpler than configuring a container but consumes substantial system resources. Hence, I'll opt for a CUPS server on a container for my approach.

Step 1. Running Your CUPS server in a container ( Easy Way with privileged container)


First you need to configure cups, open your container station and search for CUPS. I used olbat/cupsd .

In network settings, you have two options: NAT (using your QNAP IP and forwarding a port) or Bridge mode. I chose NAT and forward port 631 of host to containers 631 port.

Under Device settings, you will have to set up the container as a privileged one Without this, you'd need to SSH into your QNAP, locate your printer's USB path, and add it manually (which changes if the printer is unplugged). With privileged settings, your container gains access to all Host USB devices

This mode is not considered very safe because if the container is compromised, so is your QNAP, as it inherits Host access. In my opinion , your container is not more vulnerable than your QNAP, so its not a very unsecure setup . If you want more secure installation, look at next section.

Click on Advanced Settings
Use the NAT Settings with 631 port forwarded to 631
Tick the Privileged Mode
Mount a host volume to Container also

Finally we will also mount the public directory of your QNAP to your Container, this will be useful if you have to copy to or from container ( like driver files)

Click on create and wait for the container to be created and run.

Alternate Step 1 : Running Your CUPS server without root privilege


If you don't want to run your container in privileged mode , you will have to gain access to your QNAP's command line. First you have to enable the SSH access by going to

Control Panel > Network and File Services > Telnet SSH 

Here tick on allow SSH connection and put a port number.

Download putty and login to your QNAP using IP address and port that you specified. When you get your terminal, run this command

lsusb 

This will show you all the devices connected to your QNAP. In my case, I was intereted in Canon running on Bus 002, device number 002.

Now you have to add this device to your container. This device name would be

/dev/bus/usb/bus-number/Device-number

So in my case it was

/dev/bus/usb/002/002

Now you have to run the following docker command. What you are doing it that you are creating your container manually.

docker run --device /dev/bus/usb/002/002  -d -p 631:631  -v /var/run/dbus:/var/run/dbus --name cupsd olbat/cupsd

When you do this, your container station shows your new container running in the GUI

Remember : When you restart your printer or plug/unplug it , it might change the device number. In my case it changed form 003 to 002 after a restart, so this won't be a set and forget solution.

Step 2 : Configure your CUPS Print Server on QNAP for printer sharing


Now your QNAP has a CUPS print server running weather you used privileged container or not .You need to configure your CUPS server now Access your CUPS server with the following credentials and IP address.

ipaddress:631 
for example 192.168.1.55:631
username:print
password:print

Go to Administrator > Printers > add printer

And you see your printer there.

Make sure to tick share this printer option.

Next it presents you with a list of printers. if you don't see your printer there you will have to give a ppd for configuration. I will tell you where to find ppd in the next section

That's it, your printer will be added and the last step is to connect to this printer from windows

Step3 : Connecting your windows client to your USB printer shared on CUPS server


for this, you need your printer address. The printer address is in the form of

ipaddress:631/printers/printer_name

To find this name, go to Administration > printers > manage printers and click on your printer. in the address bar, you will see the printer address.

Go to your windows printers> add printer and select Add Manually

In the address field , use the address of the printer that you got in previous step

This is it. Now you should be able to print to this printer.

What to do if you don't see your printer in the list of printers on CUPS server

Now CUPS server that you use has the linux printer drives included . However it is possible that you don't find your printer. I couldn't find my Canon MF3010 in the list.

If that happens, you can provide cups with a PPD file ( Printer description file). I realized the hard way that this file is not published on vendors site as standalone download.

What I did was download the RPM file for linux. Used 7 Zip to extract the contents and found it under the following directory inside rpm file

cnrdrvcups-ufr2-uk-5.70-1.18.i386.rpm\cnrdrvcups-ufr2-uk-5.70-1.18.i386.cpio\.\usr\share\cups\model\

What to do if you get rastertoufr2 not found

With PPD file installation, you may on some printers get the following error

	Idle - "File "/usr/lib/cups/filter/rastertoufr2" not available: No such file or directory"

If you do get this error , you would have to install the entire driver set for your operating system.

Download the driver set for LINUX from your printer vendor website, unzip it and place it in your /Public directory on QNAP. Remember , we earlier mounted /Public of QNAP to /Public of container ? That will come in handy now.

Click on your container and on terminal. make your install script installable by running chmod 755 . You will find the install script in the root of the driver folder

Now run the install.sh script itself. After this you will have all the drivers available in your container and they will show in CUPS server too.

Canon MF3010 showing in CUPS server driver list after installation

PNP offers QNAP Support services in UAE

PNP is the largest QNAP Sub Distributor and service partner in the UAE. Our Data Storage expertise has earned us the prestegious GEC award twice. Contact us for your QNAP needs.