CUPS

Well, I did it. I got CUPS working with my network Brother mono laser. It wasn't easy, so I took detailed notes and I've posted them here for any fellow sufferers to use:

Fresh install of FreeBSD using static IP (192.168.0.6):
uname -a
FreeBSD acer 14.0-CURRENT FreeBSD 14.0-CURRENT #0 main-n263002-743516d51fa7: Thu May 18 07:36:18 UTC 2023 root@releng1.nyi.freebsd.org:/usr/obj/usr/src/i386.i386/sys/GENERIC i386

Install CUPS and Avahi (about 30 minutes):
# pkg install cups cups-filters avahi nss_mdss
(Note: It might be better to use avahi-app)

Edit /etc/rc.conf
Add:

cupsd_enable="YES"
devfs_system_ruleset=desktop
dbus_enable="YES"
avahi_daemon_enable="YES"



Edit /etc/devfs.rules
Add:

add path 'lpt*' mode 0660 group cups
add path 'ulpt*' mode 0660 group cups
add path 'unlpt*' mode 0660 group cups

Edit /etc/nsswitch.conf like this:
#
# nsswitch.conf(5) - name service switch configuration file
# $FreeBSD$
#
group: compat
group_compat: nis
hosts: mdns4_minimal [NOTFOUND=return] files dns
netgroup: compat
networks: files
passwd: compat
passwd_compat: nis
shells: files
services: compat
services_compat: nis
protocols: files
rpc: files

Modify cupsd.conf:
edit /usr/local/etc/cups/cupsd.conf
# Restrict access to the server...
<Location />
Order allow,deny
allow 192.168.0.*
# mg ^^^^
satisfy any
# mg ^^^^^
</Location>

# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
allow 192.168.0.*
# mg ^^^^^^
</Location>

# Only listen for connections from the local machine.
# Listen localhost:631
Port 631
#mg ^^^

Restart
# shutdown -r now

Access web interface at 192.168.0.6:631

select printer maker - generic
select printer - PCL

Description: Brother HL-2150N series
Location: Local Printer
Driver: Generic PCL Laser Printer (grayscale)
Connection: dnssd://Brother%20HL-2150N%20series._pdl-datastream._tcp.local/
Defaults: job-sheets=none, none media=iso_a4_210x297mm sides=one-sided

Great success. Feel free to add improvements below.
 
Finally... got this to work! Thanks for the post. I used avahi-app and not avahi, and I installed brlaser for the drivers which means I get to pick my actual printer driver (DCP-L2550DW) and get its all its goodies. This was on 13.2, but I expect it's the same on 14.
 
Finally... got this to work! Thanks for the post. I used avahi-app and not avahi, and I installed brlaser for the drivers which means I get to pick my actual printer driver (DCP-L2550DW) and get its all its goodies. This was on 13.2, but I expect it's the same on 14.
Can you expand on "I installed brlaser" please.
 
Me vs CUPS, round 2. Seconds away...
# pkg install cups # pkg install hplip # pkg install gutenprint # pkg install brlaser
(NB. Note I haven't installed Avahi or mss_mdss)

edit /etc/rc.conf as follows:
cupsd_enable="YES" devfs_system_ruleset="system"

edit /etc/devfs.rules as follows:
[system=10]
add path 'unlpt*' mode 0660 group cups add path 'ulpt*' mode 0660 group cups add path 'lpt*' mode 0660 group cups add path 'usb/X.Y.Z' mode 0660 group cups

# Where ^^^^ X.Y.Z = /dev/usb directory
# Find device in dmesg = ugenX.Y -> usb/X.Y.0. Probably 1.2.0. So add path 'usb/1.2.0' mode 0660 group cups

edit usr/local/etc/cups/cupsd.conf to look like this (don't use this as-is, use only as an example):
LogLevel warn PageLogFormat SystemGroup wheel MaxLogSize 1m ErrorPolicy stop-printer # Allow remote access Port 631 Listen /var/run/cups/cups.sock Browsing Yes BrowseLocalProtocols dnssd BrowseAllow 192.168.0.* BrowseAddress 192.168.0.* DefaultAuthType Basic DefaultEncryption Never WebInterface Yes IdleExitTimeout 600 <Location /> # Allow remote access... Order allow,deny Allow all </Location> <Location /admin> </Location> <Location /admin/conf> AuthType Default Require user @SYSTEM </Location> <Location /admin/log> AuthType Default Require user @SYSTEM </Location> <Policy default> JobPrivateAccess default JobPrivateValues default SubscriptionPrivateAccess default SubscriptionPrivateValues default <Limit Create-Job Print-Job Print-URI Validate-Job> Order deny,allow </Limit> <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set- Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit CUPS-Get-Document> AuthType Default Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS- AuthType Default Require user @SYSTEM Order deny,allow </Limit> <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Print AuthType Default Require user @SYSTEM Order deny,allow </Limit> <Limit Cancel-Job> Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit CUPS-Authenticate-Job> AuthType Default Order deny,allow </Limit> <Limit All> Order deny,allow </Limit> </Policy> <Policy authenticated> JobPrivateAccess default JobPrivateValues default SubscriptionPrivateAccess default SubscriptionPrivateValues default <Limit Create-Job Print-Job Print-URI Validate-Job> AuthType Default Order deny,allow </Limit> <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set- AuthType Default Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS- AuthType Default Require user @SYSTEM Order deny,allow </Limit> <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Print AuthType Default Require user @SYSTEM Order deny,allow </Limit> <Limit Cancel-Job CUPS-Authenticate-Job> AuthType Default Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit All> Order deny,allow </Limit> </Policy> <Policy kerberos> JobPrivateAccess default JobPrivateValues default SubscriptionPrivateAccess default SubscriptionPrivateValues default <Limit Create-Job Print-Job Print-URI Validate-Job> AuthType Negotiate Order deny,allow </Limit> <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs ... AuthType Negotiate Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class ... AuthType Default Require user @SYSTEM Order deny,allow </Limit> <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Print ... AuthType Default Require user @SYSTEM Order deny,allow </Limit> <Limit Cancel-Job CUPS-Authenticate-Job> AuthType Negotiate Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit All> Order deny,allow </Limit> </Policy>

When adding the printers in CUPS set the names to something simple, for example:
deskjet
network_laser
usb_laser

CUPS -> add printer:
In browser 192.168.0.4:631
HL-L2300D->needs Brother-HL-L2300D-series.ppd available

Network laser HL-2150N ->jet direct->socket://192.168.0.11:9100->generic pcl

Deskjet -> make sure address = socket://192.168.0.12

NB: There is a bug (or feature) in CUPS where '.local' is added to driver names inappropriately. Watch closely for names with a '.local' extension as this is the cause of the 'printer not found' errors.
What to do about it? Specify the file name directly, using generic printer descriptions (see the details for the Brother HL-2150n network laser above).

command line printing:
$ /usr/local/bin/lp filename
NOT
$ /usr/bin/lp filename
So to avoid command name conflicts change the old lpd/lpr command names:
# cd /usr/bin # mv lp lp.old

Enjoy!
 
Last edited:
add path 'unlpt*' mode 0660 group cups add path 'ulpt*' mode 0660 group cups add path 'lpt*' mode 0660 group cups add path 'usb/X.Y.Z' mode 0660 group cups
Unless something has changed, you should not need to access the 2 different line printer interfaces and the usb interfaces if the print job is going over the network.
 
A follow up. Don't use the 'Edit configuration File' or 'Change Settings' buttons in the 'Administration' page, however much you're tempted, you'll instantly be cut off if you're working over the lan as the 'localhost' line is put back in. A bug I assume. On the subject of bugs you might get 'Not Found' messages from the 'Manage Printers' and 'Manage Classes' button in the 'Adminstration' page. Use the 'Classes' and 'Printers' tabs on the menu at the top instead.
 
Recently fixed: the Manage Printers and Manage Classes buttons.

… Don't use the 'Edit configuration File' or 'Change Settings' buttons in the 'Administration' page, however much you're tempted, you'll instantly be cut off if you're working over the lan as the 'localhost' line is put back in. A bug I assume. …

http://127.0.0.1:631/admin is not bugged for me (no switch to localhost after use of those two buttons), did the issue occur only with other (non-127.0.0.1) addresses?

Code:
% pkg iinfo ^cups$
cups-2.4.10_1
% uname -mvKU
FreeBSD 15.0-CURRENT main-n270997-d3bb35d4e51b GENERIC-NODEBUG amd64 1500019 1500019
%
 
Recently fixed: the Manage Printers and Manage Classes buttons.



http://127.0.0.1:631/admin is not bugged for me (no switch to localhost after use of those two buttons), did the issue occur only with other (non-127.0.0.1) addresses?

Code:
% pkg iinfo ^cups$
cups-2.4.10_1
% uname -mvKU
FreeBSD 15.0-CURRENT main-n270997-d3bb35d4e51b GENERIC-NODEBUG amd64 1500019 1500019
%
If you're working at the system you're administering it won't make a difference. Only if you're working at another system, over the network, do you get cut off. Getting access to, and full functionality from, the gui over the network is difficult. The FreeBSD site article says this: "If the CUPS server is on another machine on the network, substitute the server’s local IP address for localhost". However it's much more difficult than that.
 
Back
Top