Friday, February 5, 2021

Driverless printing in Debian Part II - Sharing printers over the network

Previously, I wrote about the idea of driverless printing: a common language shared between computers and printers that allows a printer to tell a computer "this is what I can print", and the computer to send the print job to the printer in a format it can print.

Thus removing the tedious necessity of installing drivers to use a printer, and allowing any device to print to any printer.

I also wrote about how my printers didn't have the common language required for driverless printing.

In this post I'm going to write about how it is possible to print from a Linux computer or Android device to printers connected to the network without installing drivers: by sharing printers over the network. (You do need one computer with the drivers installed.)

This is something I discovered by accident. I noticed when using my desktop PC running Debian Buster Gnome that the two wireless printers on my home network were listed twice in printer settings, the second listing being suffixed with the name of my laptop.

This confused me for a while until I realised that by default my laptop publishes network printers connected to it, and my desktop detects and adds the printers as shared network printers via the laptop.

And then I realised that it is possible to use the printers shared by the laptop even without the printer driver installed on a device. The printers appear on my Android phone, and I can print to them from it.

Which, of course, is useful.

So how does it work? Well, it seems the laptop has a system to publish printers connected to it so that they are available to other devices connected to the network, which can then use the common language I mentioned earlier - Internet Printing Protocol (IPP) - to pass the print job to the laptop, which can then pass it to the printer.

In an ideal world of course, my printers would have the version of the shared language that would allow any device to connect without a driver - IPP Everywhere™ - but at least this way phones and tablet on the home network can print without a driver.

The system that publishes printers in this way is a Zero-configuration networking (zeroconf) multicast DNS/DNS-SD service. Something that Apple implements with Bonjour (hello - understandable) and Linux with Avahi (a genus of woolly lemur - mkay).

Printers are discovered in Linux by cups-browsed.

Bonjour is built into printers so they can advertise themselves on the network, Debian has Avahi so it can advertise connected printers and cups-browsed so that it can discover them, and Android has Network service discovery (NSD) so it can discover connected printers.

Of course you may not want your computer to add every printer discovered on the network, especially if they are a duplicate of an already-installed printer. This could be seen as a bug not a feature.

However, it is possible to disable publishing of printers connected to the computer.

The option was ticked by default in XFCE in Debian Bullseye, but left unticked by default in Gnome in Debian Buster.

So, if you want to print from a Linux computer, or an Android device, but don't want to/can't install the driver, this is a way to do it. I think everything was installed by default in Debian, with the only difference being that sharing was enabled in one installation and not another. In other distributions it may be necessary to install Avahi or cups-browsed.

And of course this sort of thing is possible in Apple and Windows too, but I don't have Apple or Windows devices. If you do, this guide may be useful.





No comments:

Post a Comment