Serving AirPrint via RaspberryPi

Serving AirPrint via RaspberryPi

So I’ve got a Pi, a few Apple devices and a Brother network-enabled laser printer, so I thought: “Hey, wouldn’t it be wonderful if I could print directly from the iDevice to the printer?”

It really would, but Brother’s app requires that you (re-)open whatever needs printing in their built-in browser, so that’s a few extra steps than I am happy with for printing from Safari, etc. (NOTE: The network scanning function from the app is pretty amazing, however)

The workaround: Use the PI as an AirPrint server (since it’s already handling other ‘always-on’ functions) – easy peasy! I’ve seen Brother’s got a Linux driver on their website!

UPDATE: Something got borked, so I did some debugging; turns out the ‘share printers’ option needs to be set in CUPS (see Step1’s update), and with the MIME types configured (maybe? Added step5), CUPS support Airprint directly (iOS 6+), without avahi??

Step 1: Install/setup CUPS

Easy enough, I followed these steps, which basically amount to:

  • Install CUPS: sudo apt-get install cups
  • Allow your user admin rights (to configure cups): sudo usermod -a -G lpadmin pi
  • I skipped some of the more questionably secure mods in the CPUS config-file, namely:
    • allowing printing via (CUPS server) to any machine on the LAN (since my printer is already network-enabled & I only need to add AirPrint support), and
    • opening up the admin interface to any machine on the LAN (since I have a monitor on my pi and am comfortable working with X11-redirects)
  • Restart CUPS: sudo /etc/init.d/cups restart
  • Add a printer via the admin WebUI (http://localhost:631)

UPDATE: You MUST check the ‘Share printers connected  to this system’ option, even though this seems less secure – see the UPDATE below for more on security.

GREAT! My printer is detected by CUPS! …Oh wait, my model isn’t listed 😦

UPDATE: For the security-minded, I came across this little gem by Marcus Povey: Limit printer access to your local LAN and loopback via /etc/cupsd.conf:

<Location />
  Order Deny,Allow
  Deny From All
  Allow From
  Allow From

Don’t forget! You need to specify the NETWORK address, not the address of a specific host, or it will get stuck! (Thanks lifeafter2am!)

Stuff I tried, but ultimately gave up on:

  • Remember that wonderful Linux driver on Brothers’ website? Download and install the .deb package… Oh wait, it’s an x86 driver 😥
  • Finding a .ppd in the cupswrapper and LPR .deb packages (ar vx <filename>.deb to open them, in case you were wondering)

Then, the jackpot. A fine gentleman named Peter De Wachter was kind enough to build a brother driver with which CUPS can print to a few models of DCP- laser printers – INCLUDING MINE! The source code is graciously shared on GitHub under a GPLv2:

If you run into similar issues (missing linux armhf driver support from the manufacturer), you can try finding a suitable printer driver here:

Step 2: Installing the brlaser driver

Special thanks to ‘hal58’ who wrote the ‘Jackpot’ post referenced above about getting his brother printer working with his Pi:

His instructions amount to:

  • Download the source code .zip from
  • Install CUPS and software libraries/compilers:  sudo apt-get install cups build-essential libcups2-dev libcupsimage2-dev automake
    • I had an issue with ‘automake’, and hal58’s ‘automake-1.11’. An ‘apt-get update’ cleared it up.
  • Prepare, configure, build and install the driver: ./; ./configure; make; sudo make install
  • Restart CUPS service: sudo service cups restart

Hooray! Now back to the original guide!

Step 3: Finish adding the printer

Getting back to the interrupted ‘Add Printer’ process in CUPS WebUI, under the ‘Model:’ field just select the line ending with “using brlaser v3 (en)”

That’s it! 1hr later, I can print!! – Who says Linux/RPi aren’t fun? 😉

 Step 4: Install  avahi-daemon

UPDATE: This step (avahi-daemon) may not even be necessary!?
While debugging (after finding out my CUPS was not set to share printers), I had visible AirPrint printers in my iPhone: “AirPrint-Brother” (from /etc/avahi/services/airprint.service) and “Brother DCP-XXXX” (directly from CUPS??)

Most of the guides tell you to simply sudo apt-get install avahi-daemon, but somehow omit a key step: avahi’s .service config-file! (SERIOUSLY!?)

Step 4a: setting up the AirPrint service (avahi-daemon)

The ones that do seem to be aware that avahi is not simply plug-and-play, refer to a python script that will auto-create and configure the .service file required.

Disclaimer: My malfunction is that I don’t like running a random script called “” from github and hoping for the best… call me paranoid. Part of the problem is that I don’t know enough python to (time-effectively) audit that the script is actually doing what it’s advertised to do, and nothing more.

Fortunately, good ol’ google led me to archlinux, who gave a sample config-file and listed what should be customised: As far as I can tell:

  • adminurl is the same link as you would use to administrate your printer via CUPS’ webUI (Administration > Manage Printers > ‘PrinterName’),
  • rpand ty are sub-strings of adminurl, and
  • as for nameand note, just pick a printer name and location-hint that make sense (will be displayed in the iOS device looking for printers)

Copy-paste the sample from ArchLinux into a text file and update the fields above before saving, e.g.: sudo vi /etc/avahi/services/airprint.service

A quick sudo service avahi-daemon restart and you’re set!

Step 5: Adding MIME types to CUPS (UPDATED)

While debugging, I came across this post by Friedrich Hotz, and added the MIME types indicated and it now seems that CUPS supports AirPrint on its own? I’ve deactivated the avahi ‘.services’ files (sudo mv airprint.service and my Brother DCP-XXXX is still detected on my iPhone! And it prints too!

echo ”image/urf urf string(0,UNIRAST<00>)” >  /usr/share/cups/mime/airprint.types
echo ”image/urf application/pdf 100 pdftoraster” > /usr/share/cups/mime/airprint.convs

Let me know if this helped you get a similar setup going on your own Pi.

Looks like Duplex printing will be a battle for another day 🙂

One thought on “Serving AirPrint via RaspberryPi

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s