This is the process for setting up cups in Linux. I have another page that is more of a cheatsheet for quick use.
The goal is to figure out how to set up any arbitrary printer which I'm still not comfortable with.
I'm only setting up plain text printing so I'm not using any specific drivers.
Given an IP, the first step is to figure our if I need to use JetDirect or LPD.
nmap 192.168.141.25
PORT STATE SERVICE
80/tcp open http
81/tcp open hosts2-ns
139/tcp open netbios-ssn
515/tcp open printer
9100/tcp open jetdirect
LPD uses port 515 and JetDirect uses port 9100. The above device accepts both and so we technically have the option.
To add a printer with lpd we do the following:
lpadmin -p PRINTER3 lpd://192.168.141.25/pr
cupsenable PRINTER3
cupsaccept PRINTER3
echo "ASD" | lp -d PRINTER3
This should send a print job successfully to the printer. However I had problems where the printer would become disabled as soon as I sent a job.
lpstat -t
printer PRINTER3 disabled since Sat 22 Dec 2021 01:17:45 PM UTC -
reason unknown
I haven't figured out why this happens. Luckily setting up JetDirect appears to have worked.
The steps are very similar but we now use the socket protocol:
lpadmin -p PRINTER3 -v socket://192.168.141.25:9100
cupsenable PRINTER3
cupsaccept PRINTER3
echo "ASD" | lp -d PRINTER3
We can make sure there were no issues with the printer by doing lpstat.
lpstat -t
printer PRINTER3 is idle. enabled since Sat 22 Dec 2021 01:33:03 PM UTC
We can see the completed jobs by checking lpstat as well:
lpstat -W completed
PRINTER3-20 root 1024 Sat 22 Dec 2020 01:33:03 PM UTC
Hopefully this idea of using nmap to find out ports are open and trying both lpd and jetdirect will make setting up printers easier.