Using CUPS to enable AirPrint on a non-AirPrint printer connected to an AirPort

summary

To enable AirPrint on a printer already connected to an AirPort Express, install and setup cups (to serve the printer) and avahi (to theoretically discover the printer and advertise the printer as AirPrint-capable).

In CUPS, add a printer using “AppSocket/HP JetDirect” with the address socket://[name-or-IP-of-your-airport-express]:9100.

background

The AirPort Express (MC414LL/A, A1392) has a USB port that can be used to share a printer on the network.

The AirPort will take care of providing and advertising the printer on the network (via Bonjour), but the network printer won’t support AirPrint.

DNS-SD

In the ideal setup, avahi-daemon will detect the printer’s Bonjour broadcasts, and you can use cups to seamlessly add the printer for sharing: cups on Debian already supports AirPrint (thanks to their hard work!).

To detect the printer, we can use lpinfo:

$ sudo /usr/sbin/lpinfo --include-schemes dnssd -v

network dnssd://[printer-name]._pdl-datastream._tcp.local/

In CUPS, you will be able to add the printer as usual, with this address (dnssd://...), along with drivers and so on, but you won’t be able to print anything to it.

The advertised printer address is self-assigned (169.254.0.0/16), which might be why CUPS can’t send jobs to the printer?

$ avahi-browse _pdl-datastream._tcp -t --resolve --no-db-lookup

= eth0 IPv4 [printer-name] _pdl-datastream._tcp local
hostname = [AirPort-Express.local]
address = [169.254.76.153]
port = [9100]
txt = [...]

A reboot of the AirPort will provide the correct address temporarily, but the advertised service eventually reverts to a self-assigned address.

workaround

The fix, which I found documented here, is to add the IP address or name of the AirPort in CUPS:

  1. browse to https://[name-or-IP-of-CUPS-server]:631
  2. Administration -> Add Printer
  3. Other Network Printers -> AppSocket/HP JetDirect
  4. Connection: socket://[name-or-IP-of-your-airport-express]:9100
  5. finish installation as usual

On an iOS device, try printing something via AirPrint. The printer should automatically show up.