I would like to add AirPrint support to a legacy Brother network printer and, if possible, also have AirPlay audio streaming to a stereo on the same shelf. I ran across a great tutorial on how to do just that by installing CUPS (for AirPrint) and Shairport (for AirPlay) on a Pogoplug with Arch Linux. This made me wonder if the ever more extensible FreeNAS platform could be coaxed into doing the same thing -- I already have a FreeNAS server for backups and rather than having a Pogoplug and my server running at the same time, having everything run on one device seems more efficient. However, I have been unable to find any tutorials aimed at accomplishing this goal.

Is there a relatively straightforward way to get CUPS and Shairport on FreeNAS 9 (perhaps in a "jail")?

4 Answers 4


Following @Roland Smith's suggestion, I created a portsjail on my FreeNAS. I gave the portsjail a static IP address, disabled VIMAGE and set the default gateway. I then went into the FreeNAS web-based shell and did the following:

  • Type jls, note the number of the jail and then type jexec [number] sh.
  • Once in the jail type pkg install cups hplip py27-cups.
  • Next utilize the CUPS.conf from the tutorial mentioned in my question:

    cd /usr/local/etc/cups
    mv cupsd.conf cupsd.conf.org
    wget http://dl.dropbox.com/u/42238/pogoplug/cupsd.conf
  • Follow the steps in the FreeBSD tutorial on CUPS, save for the part concerning SMB sharing to finish setting up CUPS. Finishing by starting CUPS:

    /etc/rc.d/devfs restart
    /usr/local/etc/rc.d/cupsd restart
  • Then, log into http://[hostname]:631 and set up the printer (unfortunately, CUPS auto detection of network devices doesn't seem to be working in my BSD jail, so I had to manually set up the Brother MFC-7820N using the HP JetDirect option. I printed a test page to confirm my printer was working. I set the printer to be shared during the setup and enabled sharing on the main CUPS administrative web page.

  • To provide for iOS 6 and above support, enter the following, slight variation to the most common fix in the jailed shell:

    echo "image/urf urf string(0,UNIRAST<00>)" > /usr/share/cups/mime/airprint.types
    echo "image/urf application/vnd.cups-postscript 66 pdftops" > /usr/share/cups/mime/airprint.convs
  • Now, use the handy AirPrint generator to create an Avahi service advertisement:

    cd /
    wget -O airprint-generate.py --no-check-certificate https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py
    python AirPrint-generate.py
  • Next, exit the jail to return to the main server. Then, I copied the AirPrint service to the server's own avahi system (since running Avahi in the jail doesn't seem to work reliably). However, because the /etc/ folder is recreated each time FreeNAS starts, instead of copying it directly, we need to create a Pre-Init script on the FreeNAS to copy it on startup. To do that, login the FreeNAS administrative interface again, click on the System category and then "Add Init/Shutdown Script," set the type to "Pre Init" and enter the following as the command:

    cp [PathToYourJail]/usr/local/etc/avahi/services/AirPrint-*.service /etc/local/avahi/services
  • Click "OK," reboot and you should find that your AirPrint device(s) are now being broadcast by the FreeNAS.

  • From there, you should be good to go!

I've linked to my two remaining SuperUser questions concerning CUPS auto discovery and Avahi shutting down within the jailed environment. If anyone has suggestions on how to resolve those problems, I'd be grateful, however those do not prevent the above from working, they simply make it unnecessarily inelegant.

I have not yet tried to see if it is possible to get audio support to work on FreeNAS for AirPlay; I may try that at some point still.

  • 1
    To add to Timothy's very helpful answer (I can't comment on it with this website since I don't have enough "Reputation" points), for me in a jail on FreeNas, the cups MIME configuration directory was "/usr/local/etc/cups" and not "/usr/share/cups/mime/".
    – Greg Quinn
    Dec 15, 2013 at 4:53
  • With Freenas 9.3, restarting devfs doesn't work (devfs rule: ioctl DEVFSIO_RGETNEXT: Operation not permitted). Seems some stuff has changed with BSD 10.0...
    – damian
    Jan 6, 2015 at 19:14
  • 1
    Thanks, CUPS seems to be working. To print from OSX I had to point the Printers & Scanners GUI at IPP address http://freenas.local:631/printers/<printerName>, then change the the driver to raw on the OSX client (which required doing sudo cupsctl WebInterface=yes on the OSX client then going to http://localhost:631). I can't figure out how to get the devfs rules to apply in the jail though, so I have to manually chmod a+rw /dev/ulpt0 in the jail every time it starts.
    – damian
    Jan 10, 2015 at 17:57
  • 1
    pkg install cups hplip py27-cups gives me an error: "No packages matching 'py27-cups' have been found.." any idea?
    – Quest
    Jan 27, 2016 at 21:13

Both CUPS and shairport are available in the FreeBSD ports collection.

You can install them on FreeNAS as documented here.

Using packages is probably the easiest way. If you want to build cups with non-default options, you'll have to build from source.


With regards to the pkg install error "No packages matching 'py27-cups'. The new package is called py27-pycups. That should install.


Timothy R. Butler's answer is great, but in 2021, lots of things have changed. It's a lot simpler to get working now, I think. Here's what I did with TrueNAS 12.0-U1.1 (I picked 12.2-RELEASE for the jail):

# setup a jail which gets its own IP - I did IPv4 only

pkg install avahi cups python3 py37-pycups ncurses vim

# drivers. you will have to play with ones to find one that works for you. you can try gutenprint:
pkg install gutenprint

# or you can try hplip:
pkg install hplip

# or you can try foomatic - grab a PPD from openprinting.org. this was the only thing
# that worked reliably for me and enabled all supported resolutions without 
# advertising it as a duplex color printer, because it uses the ghostscript pxlmono 
# driver for my LaserJet 2100... maybe hplip would be great if it actually knew what 
# my printer supported properly

# enable services
echo "avahi_daemon_enable=YES" >> /etc/rc.conf
echo "cupsd_enable=YES" >> /etc/rc.conf
echo "dbus_enable=YES" >> /etc/rc.conf

# create an admin account, invite to group "wheel", fill in full name and username, leave rest at defaults

# Listen on instead of
# Allow All on /, /admin, /admin/conf, and /admin/log
# Require user @SYSTEM on /admin
# AuthType Default on /admin
vim /usr/local/etc/cups/cupsd.conf

# stop making avahi advertise SSH/SFTP
rm /usr/local/etc/avahi/services/sftp-ssh.service /usr/local/etc/avahi/services/ssh.service

# start services
/usr/local/etc/rc.d/dbus restart
/usr/local/etc/rc.d/avahi-daemon restart
/usr/local/etc/rc.d/cupsd restart

# visit http://jail:631 and setup printer, share it, configure, set as server default, print test page to check proper driver

# with latest CUPS, you do NOT need to add any mime conversions! but because apple,
# you have to publish the right stuff to ZeroConf. this script does this:

fetch -o /usr/local/bin/airprint-generate.py https://raw.githubusercontent.com/tjfontaine/airprint-generate/master/airprint-generate.py
chmod +x /usr/local/bin/airprint-generate.py
cd /usr/local/etc/avahi/services

# You may want to edit the script to add feature flags, see https://wiki.debian.org/CUPSAirPrint for more details.
# You may also want to add application/vnd.cups-pdf to the DOCUMENT_TYPES set to True


Avahi will pick up the service immediately and begin publishing it. Edit the file that the script outputted if you want to change how stuff rendered or the features announced or whatever. Debian's docs say you have to have something in the URF record other than "none", but this works for me on iOS 12. You can fill in the URF record from the Debian wiki example if you want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .