iPad AirPrint using Ubuntu server and a network printer

Like a lot of other folks, I recently updated my iPad to iOS 4.2.1 and began looking to see what worked and what didn’t. After getting over the mute switch, I wanted to try AirPrint. I don’t know how much I’ll ever use this feature but it bugs me that support is limited to so few printers. I have an HP OfficeJet Pro L7680 All in One. I loathe this printer, and don’t recommend buying one but it’s the printer I own. Anyway I thought maybe if I could find enough information on the Internet I could configure my Linux VM to serve up my “incompatible” printer.

Most of what follows is based on a blog entry from Ryan Finne with added help from a blog entry by tjfontaine. I won’t repeat their great work here. Instead, I hope to add more of the noob perspective since I didn’t even know what CUPS was until I began this quest.

My Linux VM is a minimal install of Ubuntu 10.04 server with samba, vsftpd, and nfs. I use it primarily to share a big USB drive to the Windows boxes in my home and also to the ESXi server hosting it. My VM is named allspice. However, I do not run a local DNS so everything was done using it’s static IP address of 192.168.8.199. Your mileage may vary.

Step 1 was to get the files necessary to support printing from the VM:

sudo apt-get install cups cups-pdf hplip

This got me the CUPS files, the PDF filter, and the support files for my HP printer. With no GUI on the server, the next step was to gain access to the CUPS web interface from another box. I had to modify 0/etc/cups/cupsd.conf because the default file only allows localhost access. Below is a summary of my changes:

#Listen localhost:631
#Listen /var/run/cups/cups.sock
Port 631
ServerAlias *

<Location />
 Order allow,deny
 Allow @LOCAL
</Location>

<Location /admin>
 Order allow,deny
 Allow @LOCAL
</Location>

CUPS Server SettingsAfter restarting CUPS, I could browse https://192.168.8.199:631 and see the web interface. There I changed the basic settings on the configuration tab as noted. Once the server restarted and the page refreshed, I clicked the Find New Printers button. My network printer was located and included in the list of printers to add. In my case my printer model showed up twice in the list. Both entries appeared identical HP HP Officejet Pro L7600 (Officejet Pro L7600 [9CD796]) however viewing the page source revealed that one had a URI of:

dnssd://Officejet%20Pro%20L7600%20%5B9CD796%5D._pdl-datastream._tcp.local

while the other had a URI of:

dnssd://Officejet%20Pro%20L7600%20%5B9CD796%5D._printer._tcp.local

I chose the one ending in _printer._tcp.local. I named it HPL7680, and chose the appropriate driver from the offered list. The last thing I did was to print a test page and verify that the VM was capable of printing.

Next I jumped in head first and followed my source’s instructions only to get nowhere fast. Something was missing. After a half a day of no-progress I slept on it, and woke up with a fresh idea. I have one other Linux box, an Asus EEE netbook which also is running Ubuntu. I pulled that out and sat down to try and print Ubuntu to Ubuntu. Once I fed it (just) the address of the print server, the netbook detected my printer at ipp://192.168.8.199:631/printers/HPL7680 and I was able to print a test page.

Now I knew my print server was serving up my configured printer to my network. But the iPad still wouldn’t display it. The problem had to lie in the advahi configuration. I re-ran tjfontaine’s script and had a look at the file it generated:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">AirPlay HPL7680 @ %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/HPL7680</txt-record>
    <txt-record>note=HP Officejet Pro L7600</txt-record>
    <txt-record>product=(GPL Ghostscript)</txt-record>
    <txt-record>printer-state=3</txt-record>
    <txt-record>printer-type=0x80901c</txt-record>
    <txt-record>pdl=application/octet-stream,application/pdf,application/postscript,image/gif,image/jpeg,image/png,image/tiff,text/html,text/plain,application/openofficeps,application/vnd.cups-banner,application/vnd.cups-pdf,application/vnd.cups-postscript</txt-record>
    <txt-record>adminurl=ipp://localhost:631/printers/HPL7680</txt-record>
  </service>
</service-group>

Using the default options, the file it created contained adminurl=ipp://localhost:631/printers/HPL7680 which obviously won’t work remotely. I manually changed this to ipp://192.168.8.199:631/printers/HPL7680 and restarted the avahi-daemon.

My netbook could see AirPlay HPL7680 @ allspice but not my iPad. I tried configuring the printer on the netbook using the AirPlay configuration. Still no test page was printed. Browsing the CUPS error_log revealed this line:

E [26/Nov/2010:09:31:20 -0500] Bad URI "//printers/HPL7680" in request!

After I changed the line <txt-record>rp=/printers/HPL7680</txt-record>
to remove the leading ‘/’. I restarted the avahi-daemon and finally my iPad could see and more importantly print to the printer.

7 thoughts on “iPad AirPrint using Ubuntu server and a network printer

  1. Panagiotis Atmatzidis

    Hello fellas,

    Sorry for the late reply. I was not able to apply this on the ReadyNAS NV+ because it got stroke by a lightning(!) and was burned down via ethernet cable (the ethernet cable was not plugged into the UPS unit).

    regards

    Reply
  2. John

    Thank you so much for making this available. I was dreading the thought of getting my linux boxes airprint ready. It worked like a charm.

    Reply
  3. Josh

    I haven’t been able to get this to work.

    Syslog shows avahi not complaining about the .service file (loads ok), but I noticed that the file generated by tjfontaine’s script dMid not generate the adminurl line. I tried manually adding it, but that didn’t help either. My iphone still doesn’t see the printer. The macbook doesn’t either, but that may be because its already installed (don’t want to remove it to find out)

    Any pointers on how to troubleshoot further? How can I see what is avahi browsable ?

    Reply
  4. Josh

    I did notice this, which is promising:

    jrogers@pumba:/etc/avahi/services$ avahi-browse -a | grep AirPrint
    + eth0 IPv6 AirPrint HP1100 @ pumba Internet Printer local
    + eth0 IPv4 AirPrint HP1100 @ pumba Internet Printer local

    Still not seeing it on the iphone though. No clue why.

    Reply
  5. Nick Post author

    @Josh,

    Can’t say why it’s not working for you. Seems like it’s only working part time for me as well, but I’ve been too tied up doing real work to look into exactly why. So it probably won’t get fixed until I really really need to print something and can’t.

    As for troubleshooting, I’d say take it step by step.
    0) reboot your router (sometimes it helps).
    1) reboot your linux box.
    2) verify you can print a test from CUPS.
    3) verify that another linux box can print to the printer by it’s air-print share name.
    Once these are done, then throw apple into the mix.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>