I have a Brother LaserJet printer that I would like to share over the home network. By setting up CUPS we can make this printer available to all the laptops, iPad, and iPhone in the house.
sudo apt-get install cups
1) Setup Cups
#Listen localhost:631
Browsing On
# Restrict access to the server...
<Location />
Order allow,deny
Allow @LOCAL
</Location>
# Restrict access to configuration files...
<Location /admin/conf>
AuthType Default
Require user @SYSTEM
Order allow,deny
Allow @LOCAL
</Location>
Modify the 3 highlighted lines above which allow access to the CUPS web gui from locations other than the host machine.
sudo usermod -a -G lpadmin <username>
sudo cupsctl --remote-any
sudo /etc/init.d/cups restart
We give permission to our user to do printer administration, make cups accessible anywhere in our network, and then we restart the service.
2) Modify Samba configuration
sudo nano /etc/samba/samba.conf
[printers]
comment = All Printers
browseable = yes
path = /var/spool/samba
printable = yes
guest ok = yes
read only = no
create mask = 0700
Modify the browseable
and guest okay
to ‘yes’, set read only
to no and save the file.
Restart Samba
sudo /etc/init.d/samba restart
If you are using UFW (Uncomplicated Firewall) You need to allow port 631 through:
sudo ufw allow 631
Now try accessing the CUPs web GUI using your servers IP address with the port :631 appended at the end. Navigate to the Administration
tab and click Add Printer
Now one note. You may have to install printer drivers. my Brother HL-L2320D printer needed drivers installed first. The drivers on the Brother website works fine on my PC (i386) but did not work on the Raspberry Pi (arm) so in that case I found another driver that did work:
Brother HL-L2320D driver here (for i386)
sudo apt install printer-driver-brlaser
3) Share CUPS Printer with iOS Clients via AirPrint
sudo nano /etc/avahi/services/AirPrint-DeskJet-2130-series.service
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">AirPrint HL-L2320D-series @ %h</name>
<service>
<type>_ipp._tcp</type>
<subtype>_universal._sub._ipp._tcp</subtype>
<port>631</port>
<txt-record>txtvers=1</txt-record>
<txt-record>qtotal=1</txt-record>
<txt-record>Transparent=T</txt-record>
<txt-record>URF=none</txt-record>
<txt-record>rp=printers/HL-L2320D-series</txt-record>
<txt-record>note=Brother HL-L2320D series</txt-record>
<txt-record>product=(GPL Ghostscript)</txt-record>
<txt-record>printer-state=3</txt-record>
<txt-record>printer-type=0x2900c</txt-record>
</service>ord>pdl=application/octet-stream,application/pdf,application/postscript,application/></service-group>
Save and close the file and restart Avahi-daemon:
sudo systemctl restart avahi-daemon
You should now be able to print from your ios devices.