Airprint with CUPS on DD-WRT  

Another note to self on enabling Airprint for a legacy network printer with Avahi and CUPS on DD-WRT (HP P3005).

Prerequisites: router with DD-WRT and a USB port (to install cupsd via Entware), a network capable printer. My notes on the router setup are here.

Mostly a rehash of the tutorials from TomatoUSB1 and EzUnix2, in case those links go dead:

  • opkg install hplip-full

  • opkg install cups cups-filters cups-pdf # this was required to get CUPS to recognize application/pdf as valid filter and to enable pdftoraster needed below.

  • Add this to Firewall starup script:

      # CUPSd WebInterface (http/tcp)
      iptables -I INPUT -p tcp --dport 631 -i vlan2 -j ACCEPT
      # CUPSd printer port
      iptables -I INPUT -p tcp --dport 9100 -i vlan2 -j ACCEPT
  • Navigate to CUPS web interface http://< router-ip >:631 > Administration > Add Printer

    • Choose HP Printer (HPLIP), Continue
    • Connection: socket://< network-printer-ip >:9100, Continue
    • Provide Name, Description, Location and choose to ‘Share This Printer’, Continue
    • Choose Make: HP, Continue
    • Choose Model: HP LaserJet p3005…, Add Printer
  • Run:

      echo "image/urf application/pdf 100 pdftoraster" > /opt/share/cups/mime/airprint.convs
      echo "image/urf urf string(0,UNIRAST<00>)" > /opt/share/cups/mime/airprint.types
  • Create /opt/etc/avahi/services/airprint-hpp3005.service with the following content 3,4:

      <?xml version='1.0' encoding='UTF-8'?>
      <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
        <name replace-wildcards="yes">AirPrint HP1220C @ %h</name>
          <txt-record>note=your note</txt-record>
          <txt-record>product=(GPL Ghostscript)</txt-record>

    You could generate this file from TJ Fontaine’s airprint-generate, but that did not work for me with some Python errors I chose not to pursue.

  • /opt/etc/init.d/rc.unslung restart

Done, you should find this printer via Airprint. You can use the CUPS web interface to configure printer defaults (duplex, two-sided printing, economy/high quality etc.).

For the record, HP p3005 has a decent web interface at http://< printer-ip > and also at the CUPS port: http://< printer-ip >:631.