In Arch Linux (and Arch-based distros like EndeavourOS), it’s easy to add a network printer if you already know its address. Still, network printer discovery does not work out of the box as it happens on other distributions like Fedora or Ubuntu.
The procedure to enable network printer discovery is, of course, documented in the Arch wiki. Still, in this post, I’d like to detail the steps to achieve that just as a confirmation or as additional help documentation.
First of all, let’s install the packages for printing:
1 |
cups cups-filters cups-pdf cups-pk-helper libcups |
I also install the following packages for drivers and HP (because I have HP printers):
1 |
foomatic-db foomatic-db-engine foomatic-db-gutenprint-ppds foomatic-db-nonfree foomatic-db-nonfree-ppds foomatic-db-ppds hplip gutenprint |
Of course, we must enable the CUPS service
1 2 |
sudo systemctl start cups sudo systemctl enable cups |
We must also make sure the following packages (“avahi” and “nss-mdns”) are installed:
1 2 3 4 |
extra/avahi ... (Installed) Service Discovery for Linux using mDNS/DNS-SD -- compatible with Bonjour extra/nss-mdns ... (Installed) glibc plugin providing host name resolution via mDNS |
And that the “avahi-daemon.service” is running and enabled:
1 2 |
sudo systemctl start avahi-daemon sudo systemctl enable avahi-daemon |
Then, we must edit the file “/etc/nsswitch.conf” and change the line
1 |
hosts: mymachines resolve [!UNAVAIL=return] files myhostname dns |
into
1 |
hosts: mymachines mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] files myhostname dns |
Now, we should be able to discover local network printers.
I prefer the “system-config-printer” package for this purpose (in case you want to install it).
You can run it by searching for the application “Print Settings”. I’m showing an example in KDE:
“Unlock” by providing the password, press “Add,” and expand the “Network Printer”. If you have a firewall, like “firewalld”, you’ll be asked again for the password to change the firewall settings to enable the services for printer discovery:
Of course, you have to accept to adjust the firewall.
Then, the local network printer(s) should be discovered. In my example, my HP printer is discovered with the possible network protocols:
I chose the second one (the one with the local IP address) and HPLIP as the connection protocol (remember I had already installed the corresponding packages):
By pressing “Forward”, you wait for the drivers to be selected. You can print a “test page” and configure the printer as you see fit.
What’s the purpose of editing the “/etc/nsswitch.conf” file? And will it impact other process of the system? Thank you
it’s required to make the discovery work; it’s documented in the Arch wiki.