Sunday, September 19, 2010

Part #2 - Networking Sane

Part #2 - Installing/Configuring Saned for network scanner access.

Okay, now that I/you/the family pet can finally print through cups to your new all-in-one device; it’s time to setup and configure SANEd so everyone can scan in a document. My reasoning behind this was in the past, we had to unplug the all-in-one from one desktop, drag the laptop in the computer room, plug the scanner in, scan the documents, unplug the scanner (and if we remembered to) plug it back into the desktop. What a royal PITA to do every time we wanted to scan a document in, and even more of a PITA when your attempting to print off a document from the desktop, only to realize that the last person who used the printer forgot to plug it back into the desktop! *cough* you know who you are! *cough*.

In part 1 I talked about installing the necessary packages for sane and the hplip drivers. If you haven’t already done this, please for the love of everything holy, do this now.

Before we start getting into saned configuration, the first thing you need to do is make sure that your new fancy schmancy all-in-one works with the scanner. Now according to http://www.openprinting.org/printers my HP Deskjet all-in-one F4480 is considered a ‘paperweight’. I don’t know their reasoning behind this, and maybe their database needs to be updated. But I do know that both cups and saned support this device with the hplip driver’s. So at some point, I’ll have to update this. And the Sane page for supported devices: http://www.sane-project.org/sane-mfgs.html#SCANNERS Doesn’t even show the all-in-one. But alas, once again this does work, I promise you. To see a list of supported devices with the HPLIP device driver, go here: http://hplipopensource.com/hplip-web/supported_devices/index.html

If HPlip website says Scanning/Printing/WorldDomination is supported, then you are good to go.

From the commandline type: scanimage -L
If your scanner shows up (and it should with the hplip driver support) then you can use this device with saned. For instance with my HP F4480 I get the following result:

device `hpaio:/usb/Deskjet_F4400_series?serial=CN07DC404ZXXXX' is a Hewlett-Packard Deskjet_F4400_series all-in-one

So, now that we know that scanimage can see your scanner, time to make the necessary changes. Once again, I am doing this from an Ubuntu 10.04LTS distro, so you might have to change stuff for the distribution that you are using.

First things first, changed your inetd.conf file to allow saned access.
1. vim /etc/inetd.conf
2. add the following information: sane-port stream tcp nowait saned.saned /usr/sbin/saned saned

This will allow inetd to push the saned port through and startup the saned services. Next, make sure that the tcp port is setup properly in /etc/services
1. vim /etc/services
2. search for: sane-port
3. Should look like this: sane-port 6566/tcp sane saned # SANE network scanner daemon

Okay, now that the hard stuff is out of the way, time to setup the saned.conf file. It’s actually quite straightforward and I really only have 2 lines (for security reasons) inside of my saned.conf file
1. vim /etc/sane.d/saned.conf
2. Add the following (mileage may vary depending on your internal network)
1. data_portrange = 10000 - 10100
2. 192.168.1.0/24
As you can see, I used a CIDR network mask for my network. You can add specific ip addresses, CIDR subnets, or even ipv6.

Now save saned.conf and restart inetd
1. pkill inetd && inetd

telnet to tcp port 6566 from the server, you should get the following:
1. telnet localhost 6566
root@dino:/etc/init.d# telnet localhost 6566
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
2. If you can connect to localhost, then saned is properly setup and listening on tcp port 6566.

When I first set this up, I had issues with saned and networking. These were my steps to debugging the saned interface.
1. Stop inetd (pkill inetd)
2. start saned in debug mode: /etc/init.d/saned -d255
3. This kicks off a high-level debug to the console. From here (once you have setup the sane client..more on that in a minute) you can scan a document remotely and see the debug output. Once you are done debugging, don’t forget to restart inetd.

Okay, so it’s safe to assume that saned is now listening on port 6566. Time to do some network scanning!

Remote scanning from a linux client
1. Make sure you actually have xsane installed (get it from the repo’s)
a. apt-get install xsane xsane-common
2. Setup the sane client for network scanning
a. vim /etc/sane.d/net.conf
b. add the ip address of the saned server
c. Save and quit the file
3. Put a document in the scanner, fire up xsane from the client and see if it scans!
a. xscane will check the net.conf file and attempt to connect to the server, if it makes a valid connection, you will see the device name in the title page of xsane. From here just select scan and you should see your document loaded up on the scanner. If you are having problems, check above on how I documented starting saned in debug mode.

Remote scanning from a windows client
1. Get the sanetwain package from http://sanetwain.ozuzo.net/
2. Unzip the package and execute: ScanImage.exe
3. Click the little wrench and screwdriver icon up at the top
4. Add the ip address of the saned server and port 6566 (if you set user access, now is the time to put the user name in)
5. Either click ‘scan image’ to start scanning, or close out ScanImage.exe and open it up again...by closing out and re-opening the application, it appears that it goes out to the server and adds the remote scanning device (had to do this on windows 7, tricky bugger). Tada! you should be able to remotely scan from windows now. As i said earlier, if this doesn’t work, run saned in debug mode.

There you have it, Network scanning with sane on both linux and windows clients.

My last and final part on this blog will be on getting SAMBA, CUPS and Windows driver’s happy. As this is a royal PITA to do, muchless remember how I did this 3 days ago; I’ll probably post this final update this week.
HP Deskjet F4480 - Cups, Saned, and Samba oh my!


Part #1 Cups install/configuration


So, my old HP Deskjet all-in-one finally gave up the ghost earlier this year. Something to do with the Printer Cartridges and error’s all over the place. Well, as a family of 4 1/2(does the dog count as a half?) we really needed a new printer/scanner/copier combo, but I just couldn't justify the $100+ for a networked all-in-one with limited functionality. So alas! out comes the penguin in me. We bought a HP Deskjet F4480 All-In-One from walmart last weekend, and I set out to network share the device.

Here were my goals:
* Get Cups to share the printer to all the machines in the house
*Enable remote administration of CUPS so that I wouldn’t have to VNC to the server and administer everything
*Get the Scanner to work with saned and sanetwain (window’s Xsane equivalent) so that we can scan from the windows machine’s, along with the linux machines.
*Auto-push window’s print drivers to window’s machines so I’m not hunting down the silly CD every time I need to add a printer for guests that come in and want to print
*Secure things down so only our local subnet can print/scan/take over the world.
* Do all of this from a headless virtualbox interface


Did I accomplish my goals? yup, all but the last one. Everything worked splendid in Virtualbox during my testing phases (I test all of my new home ‘servers’ in virtualbox before pushing them out). But when I pushed it prod to my little server (AMD 1.2Ghz w/ only 1GB ram, 40GB hd, I’m a cheap bastard), my little server couldn’t keep up with all of the USB emulation between the device, server and virtualbox..CPU was at 90%+ and memory went through the roof when attempting to print. So I took it out of virtualbox until I can scrounge up enough dough to buy a decent server. (This server hosts: pop3, cups, gallery2 (our family photo gallery), vpn, nagios, and other such services through VirtualBox...so I REALLY need an upgrade at some point).

I’ll post how I did all of this, from memory (although I might miss a dependency or two).

Step 1: Download files and install services


I did all of this from my Ubuntu 10.04LTS server, so mileage may vary. First, I went to HP’s opensource website: http://hplipopensource.com/hplip-web/index.html and downloaded the .deb package (newer than what Ubuntu has in it’s repo, and fixes issues with the scanner btw). Then off to cups.org to download windows driver support (http://www.cups.org/software.php). Now time for packages and dependencies!

Checking my list of installed packages, I must assume that I installed the following (and dependencies of course):

DO FIRST: dpkg -i yourhplip-package.dpkg and install it’s called for dependencies!

CUPS: cups, cups-bsd, cups-client, cups-common, cups-pdf, cups-ppdc (for ppd manipulation), ghostscript-cups, hal-cups-utils, libcups2, libcups2-dev, libgnomecups1.0-1

SANE: sane, libsane, libsane-dev, sane-utils, xsane, xsane-common

SAMBA: samba, samba-common, samba-common-bin, system-config-samba (gui, came default for some reason)

Okay, so once the packages were installed, I set out to get cups installed and configured so that I could at least print over the network.

I’m not going to go into detail about each configuration change and what I did (although I’ll add some comments here and there in the configuration). So here is what my /etc/cups/cupsd.conf looks like (make sure you backup your config before making changes). Keep in mind, the policies were created by ubuntu when I installed the package, for now I left them alone until I can create my own policies, but it works so I’m not complaining right now.

## Go here for my cupds.conf. It appears blogger seems to think my configuration is in html and attempts to format it, oi.

http://pastebin.ca/1944437


Okay, save config and restart cups! /etc/init.d/cups restart (or if your using upstart.. restart cups).

Since I’m a CLI lover, all of this was done from an ssh session, once cups is restarted, you should be able to navigate to the cups page from anyone in (in this example 192.168.1.*) subnet. Fire up firefox (you ARE using firefox, right?) and navigate to: https://your.cups.ip:631 I say https, because by default cups wants https authentication, and you might as well get into the habit of using https for security purposes.

I hope you followed the first instruction to install the hplip driver before you started installing/configuring cups..if not, you should be able to install the .deb package for hplip before configuring your printer. Restart cups after installing hplip just in case.

Now, it’s time to install the printer! Administration - > Printers -> Add Printer ->Local Printer
In my case, it shows up as: HP Deskjet F4400 series (HP Deskjet F4400 series). Select it and click next. Give it a name, description, location and click ‘share printer’, click continue. Select your driver, if it’s not listed..search your server for the *.ppd file for your printer (this is what I had to do for the hp4480), unzip the ppd file, and copy it over to the machine that you are browsing cups from, then add the .ppd file). Once this is done, click ‘Add Printer’.

Tada! Now you have a shared network printer with cups.

From a linux client, you can add the printer via the ipp address (In cups, click ‘printers’ and click the printer..up in the address bar, copy the url, and paste for ipp printing). For windows client’s, if you have ipp setup in windows (more on that in part 2/3) you can do the following (example is with Windows 7)
Start -> Devices and Printers -> Add Printer -> Add network printer ->The Printer I want isn’t listed -> Select a shared printer by name ->Copy/Paste the URL as above into this and click next.

For some people this may work (surf the net for ‘IPP printing in Windows 7’ to find out how you enable ipp printing in windows 7...can’t remember this off the top of my head). For me, and for whatever reason this didn’t work very well. So I opted to use samba in order to push windows drivers out to my connected clients. More on this in the next part.

Part 2 will cover Samba/Sane configurations with Cups for sharing your scanner and pushing out windows drivers.