After recently deciding to switch to OpenBSD full time for my main workstation, I needed to set up printing properly. Yes, I know…hard copy. But I am a bit old school, and besides, some things just need to be put on real paper to give to real people; in my case, my birthday was coming up and I needed to print my amateur radio license to renew my Bronco‘s license plate, which bears my callsign. The tag office, for some inexplicable reason, requires anyone with this particular special plate to prove the radio license status in person with a printed copy of the license every year, despite always having it on file from the first time one applied for such a plate. “Brazil” wasn’t just a movie, it was a warning.
Anyway, to do so I would need to set up my HP OfficeJet printer, connected wirelessly to the network, on OpenBSD. I chose to do this using HPLIP and CUPS as they are both in ports, I am familiar with how they work, and my printer is old enough that its PPD (driver) file is included in the slightly older version of HPLIP that is ported to OpenBSD. However, after installing both packages, starting the relevant services via rcctl including Avahi, and launching CUPS and finding the printer, I could not get it to install properly. Either it would error out at the end saying the printer couldn’t be added and advise me to check the CUPS error log, or it would seemingly successfully add the printer but I couldn’t print anything and couldn’t adjust the printer settings.
After some digging around in the error log I realized it was likely a DNS issue. The printer has an address it uses to broadcast itself via mDNS, in my case “HPA8B13B1A657D.local”. It also has an IPP address that consists of its local router-assigned IP address at port 9100. Unfortunately, CUPS was not able to set up the printer using either address; the former was not found by CUPS at all and the latter would allow me to install the printer but nothing would print to it as mentioned before. I finally decided that maybe, if CUPS could see the .local address, that would be the proper one to use when setting up the printer. So all that I needed to do was fix the DNS issue by adding a line to my hosts file associating the IP adress with the mDNS address. I did exactly that:
$ echo 192.168.1.116 HPA8B13B1A657D.local | doas tee -a /etc/hosts
I went back to CUPS and added the printer, and now instead of an error message I got the actual next step in setup: Setting the printer properties! This meant that CUPS was actually communicating properly with the printer. I finished the setup and was able to print a test page with no issues.
This still leaves me wondering why mDNS (Avahi) failed to automatically associate the local IP address with the printer’s advertised mDNS name. This doesn’t happen in Linux; I simply add the printer using either the CUPS web interface or the system-config-printer dialog in Xfce and it all just works. I had all the relevant Avahi packages installed and services enabled. I don’t know if I’m going to take the time to investigate this further; I have a working printer now and that was the goal. Still, it might be a fun diversion one day if I want to kill some time.