Tuesday, June 01, 2010

CUPS and a Wireless Printer

Eric Raymond once wrote a famous essay about the difficulty of using Linux's Common UNIX Printing System (CUPS) to set up a printer over a network. Thus, when we got ChildII's new HP C4780 Wireless Printer/Scanner I was less than optimistic about getting it Hal to access it. I mean, we're talking about a wireless printer which is talking to a Verizon FIOS wireless router, and through that to a Linux computer? No way.

I should note that I wouldn't go out and buy an inkjet printer on its own, anymore, particularly an HP. But we just got ChildII a MacBook Pro (new college uses Macs, and Mac Photoshop, for art projects), and they threw in an iPod Touch (which I get to glance at longingly) and the HP (which it's my duty to set up, operate, and maintain). So we got the thing, we might as well use it. Anyway, having a wireless or networked printer for a MacBook is an essential, given that the thing only has two USB and one Firewire port.

Setting up the HP required that I use the Mac or a PC, connected by USB to the printer, to enter the network login information. Given the connection between open source software and printers this left me a little chagrined, but I'm not RMS so I let it slide. Anyway, I didn't expect the thing to work with Linux, remember?

It took about a half-hour to install the software and drivers onto a Mac, and set up the printer. We tested the printer and scanner via wireless, and it all worked fine, though the scanner was pretty slow, much slower than my USB Canon. It all worked, though.

Then it took another half hour or so to install everything on a Windows PC. Again, it all worked flawlessly.

OK, let's try our luck. I left the printer on, went downstairs to Hal, clicked on System => Administration => Printing and watched the CUPS interface come up. Hit Add, Printer, Find Network Printer. Blinked. There it was, an HP C4700 type printer. Unlike the Canon, all the drivers were already available, I didn't have to play guess-the-correct-version. Within five minutes of clicking that Printing button I was printing a test page from Hal back to the printer.

Now all is not sweetness and light. While CUPS had no problem finding the printer, SANE, the corresponding program for scanners, couldn't find the HP. Not surprising, I guess, but it would have been nice if everything worked out. Of course I'm not particularly sure what good a remote scanner does anyone, especially if, like, me, they use it primarily to scan old pictures onto a disk.

But to summarize, things have much improved since the days of ESR's essay.

And I've got to look into getting a networked color Laser printer.

Sunday, July 13, 2008

Wireless Ubuntu

You may remember that Hal's Evil Twin runs Linux as well as XP. Well, I'm going to take HsET on a long trip with me, and I wanted it set up to run Linux properly. So I downloaded a copy of the latest Ubuntu Hardy Spin and installed it.

Worked perfectly, if I used an ethernet connection.

Then it was time to try the wireless. Previously this had been painful.

And this time it looked to be the same:

Verizon FIOS gives you a router using WEP encryption. We're rather isolate out in East Bowie, so I've never bothered to change it. So to set up the network, you go to System => Network, unlock it (i.e., sudo), click on the wireless connection, edit properties to have the correct SSID, password, etc., give the configuration a name, save it, and you're off to the races, right?

Wrong. It just wouldn't work.

Until I rebooted.

Now, mind, THIS SHOULD NOT BE NECESSARY. network-manager, bless its heart, should start and stop the wireless whenever you ask. No documentation mentions the need to reboot.

But, indeed, I had to reboot. Was it HsET? Was it me? Was it Ubuntu being crazy? I don't know.

At least it works, for now.

Note that HsET still runs XP as well, so it will keep the Evil Twin moniker, at least for a while.

Sunday, April 29, 2007

Getting Feisty With the Network

When we last left our installation of Ubuntu 7.04 (Feisty Fawn) on Hal's Evil Twin, we had everything in place — except wireless networking, a rather important omission since Spouse refuses to let me string an umbilical cord through the house. (It's only 20 feet!)

Now the Fawn has what is supposed to be excellent support for out-of-the box wireless, through something called Network-Manager, which is supposed to “effortlessly switch networks.” Well that's all right, even though HsET is permanently (I hope) connected to one network, all of the time.

And the initial results were encouraging. On installation, Feisty immediately found my DLink DWL-G510 wireless card, and told me it was going to use a Restricted (meaning third-party binary) driver to talk to it, if that was OK with me. Having no other choice to get on the Internet with HsET, I said yes, offering a silent prayer to RMS for, if not forgiveness, at least understanding.

I entered the network information: SSID, WPA-PSK (or Personal) security, passphrase, and click OK. A little arrow started chasing its tail, and eventually stopped. I opened Firefox, and headed off to GoogleTM.

Nothing. Open a terminal window, enter:
ping http://www.google.com/

No response.

Obviously nothing's working.

So I went online with the Mac, which does do wireless out of the box, and started searching Ubuntu Forums. It immediately became apparent that Network-Manager didn't handle WPA, in particular WPA-PSK mode, security all that well.

So I a sulked for awhile, and then went hunting for a solution. I found it in bits and pieces all over the forum, mostly written for previous versions of Ubuntu, but still useful. The best help was from the Ubuntu Forum and the Ubuntu Guide, some of which was originally written for static IP addresses, but with information about DHCP connections as well. I'll write out the steps I used here, but for further reference you should really go back to the original thread.

  1. First, get rid of network-manager and network-manager-gnome. I used synaptic, but you should also be able to do it with
    $ sudo dpkg -r network-manager network-manager-gnome
    This shouldn't be necessary, but I found no way to just turn off network-manager, even from within Gnome. There must be a way, since that's standard Unix/Linux practice, but I couldn't find it, so I just chucked the software out the window.
  2. Install the wpasupplicant package:
    $ sudo apt-get install wpasupplicant
  3. Open up a terminal window. Just about everything from now on will be done in this terminal window.
  4. Get your WPA identity string. Suppose your Networks SSID is "Our_House," and your pass phrase is "Two cats in the yard." Then run
    $ wpa_passphrase "Our_House" "Two cats in the yard." network={
    ssid="Our_House"
    #psk="Two cats in the yard."
    psk=43c62e1ef147c7ec83636405517140842332fce597e10124598b6d1123742a4e
    }

    Note that psk is the actual WPA password for your router. Save this output somewhere for the moment.
  5. Create the file /etc/wpa_supplicant.conf. I use
    $ sudo vi /etc/wpa_supplicant.conf
    but you can use whatever editor you wish, as long as you run it with sudo. Your final file should look like this:
    ctrl_interface=/var/run/wpa_supplicant
    #ap_scan=2
    
    network={
            ssid="Our_House"
            scan_ssid=1
            proto=WPA RSN
            key_mgmt=WPA-PSK
            pairwise=CCMP TKIP
            group=CCMP TKIP
            psk=43c62e1ef147c7ec83636405517140842332fce597e10124598b6d1123742a4e
    }
    

    where obviously you replace Our_House and the psk string with the appropriate values for your network.
  6. Now we need to edit (again with sudo) the file /etc/network/interfaces to tell it about the card. Looking around the web, I find that the DWL-G510 uses the Atheros chip-set and the madwifi driver. So edit /etc/network/interfaces so that it reads the lines near the string auto ath0 read:
    auto ath0
    iface ath0 inet dhcp
    pre-up wpa_supplicant -Bw -Dmadwifi -iath0 -c/etc/wpa_supplicant.conf
    post-down killall -q wpa_supplicant
    
    (no, that last line doesn't have a “-9,” it is, indeed “-q”)
  7. Now we want this to run at startup. Note that you do not want to do this with a laptop, because you don't necessarily know which network you are going to connect to. Create a file /etc/init.d/wifi_wpa.sh with the following content:
    #! /bin/sh
    echo "* [WiFi]: Enabling WPA Supplicant ..."
    if [ -x /sbin/wpa_supplicant ]; then
    /sbin/wpa_supplicant -B -Dmadwifi -iath0 -c/etc/wpa_supplicant.conf -w
    fi
    exit 0
    
  8. Make sure the files you create are world readable, and that the last one is executable:
    $ sudo chmod +r /etc/wpa_supplicant.conf
    $ sudo chmod +rx /etc/initd/wifi_wpa.sh
    
  9. To get wifi_wpa.sh to start during the boot requires us to get it into the list of files in /etc/rcS.d. If you list the directory:
    $ ls -1 /etc/rcS.d/
    
    the scripts will execute in the order they appear on the screen. We want WiFi to start just before the networking file S40networking, and this command pretty much guarantees it:
    sudo ln -s /etc/init.d/wifi_wpa.sh /etc/rcS.d/S40netwifiwpa
    Your mileage may vary, in which case you might have to change the name "S40netwifiwpa" to make it appear just before "S40networking."
  10. Reboot, and log on. Your internet connection should be established, e.g.:
    $ ping www.google.com
    PING www.l.google.com (www.xxx.yyy.zzz) 56(84) bytes of data.
    64 bytes from od-in-f147.google.com (64.233.161.147): icmp_seq=1 ttl=243 time=11.4 ms
    64 bytes from od-in-f147.google.com (64.233.161.147): icmp_seq=2 ttl=243 time=13.4 ms
    64 bytes from od-in-f147.google.com (64.233.161.147): icmp_seq=3 ttl=243 time=14.3 ms
    
  11. You should be able to get the network running again with stop and start commands, but I haven't tried to find the appropriate sequence.

So far (three hours, two reboots) the network has been just fine, but there may be problems ahead. If so, I'll report them. I'd also appreciate any feedback from those who've tried this themselves.

Tuesday, August 16, 2005

Gee (802.11 version)

A couple of weeks ago Best Buy offered a deal on D-Link DI-524 802.11g wireless routers and D-Link DWL-510 wireless PCI adapters -- $19.95 each, after rebate. I'd wanted to upgrade our home wireless system for some time, as we'd previously been using 802.11b routers, which only have the capability Wired Equivalent Privacy (WEP) encryption as opposed to the stronger Wi-Fi Protected Access (WPA) encryption offered by the 802.11g protocol.

Now, Linux lovers, if you want me to tell you how to get the DWL-510 working, don't look any further, because I haven't the slightest idea. This box is jacked straight in to the back of the DWL-510 (Note added later: Oops! I meant the DI-524), there isn't a wireless internet card on it. This is a saga of getting things to work on an XP box and a Mac.

Well, OK, I did set up the router itself from here. You go to http://192.168.0.1, run the setup Wizard, and change the default "admin" password (there isn't one). Also change the default name of the network from "D-Link" to whatever you choose.

But you're not finished here, yet. Go to Home ==> Wireless and change the security settings so that you are running with:

  • Wireless enabled
  • A new name for the network, if you didn't already change it
  • Whatever channel you want to run on -- I've heard that practically only 1, 6, and 11 are useful, since the channels are very close together and so there is a lot of cross-talk between, say, Channels 4 and 5. The default channel is usually 6.
  • Set Mode Setting to G Mode. The on-board documentation (click on "Help") doesn't tell you about it, but "Mixed mode" would seem to enable both 802.11b and 802.11g protocols, and you don't want that.
  • Turn SSID broadcast (which sends your network name out to the world at large) to disabled.
  • For security select WPA-PSK, "Personal Mode". As I understand it, the stronger pure WPA mode secures each connection individually. That looked to be a pain, so I started, at least, with PSK, which allows you to type in one passphrase which is used by everyone wanting to make a connection to your system.
  • Hit the Apply button and wait for everything to reset.

OK, now the router is configured, and the hard-wired connection to the outside works fine.


Connecting the Mac via wireless was easy. I just temporarily disabled the SSID broadcast on the router, and the Mac found the network right away. Enter the passphrase and we're off and running.


Getting the Windows machine connected was a bit more complicated, since I had to get rid of the old wireless card and install the new DWL-510. OK, unplug everything. Bring the box out where I can open it up. Good God, it's full of dust: the air intake is completely blocked. It's a wonder the whole thing didn't just melt down. Clean it all up, uninstall the old card, open up the box for the new card. See directions that say "Install Drivers Before you install this card." Oops. Ordinarily you can ignore this, but this time installing the drivers first turns out to be a Good Idea.

So plug everything except the old wireless card back into the computer, turn it on, and install the drivers. Ignore the warning about the software not being certified as XP compatible. Turn everything back off, and install the new wireless card.

Turn the computer back on, and let it find the new hardware and finish the software installation. Now here's the important part: in the tray at the bottom right of your screen there will be a little "D". Always use this to work with the card. When you bring up the window associated with the "D", click tabs until you find a box that says something like "Use Windows to configure my wireless network settings". Uncheck this box!! Your interface will change from Window's version to D-Links. Now click on "Configuration" and enter all the stuff needed to match the information you entered for the router. I wish I could help you with this, but the manual provided, like the on-line help for the browser, doesn't seem to know about the WPA and WPA-PSK abilities of the system. So keep clicking buttons that look logical until you find the right setup, and then hit the Apply button. If you need more help, email me and I'll tell you how to send me a plane ticket so that I can help you out.

I do note that the XP is still at Service Pack 1. If we were at SP2 it might be easier to do all of this stuff.

Anyway, the connection now works.

Maybe it's a security issue, but the login connection works a bit strangely under XP. If the first user to log on has the phasephrase set, then everyone logging onto the machine afterward can also use the connection. So if I set up Bob's account to use the D-Link, Mary can use it as well if she logs in after Bob, and, in fact, I can't change Mary's account information at that time. However, if Mary logs in first, she can't use the D-Link until she sets up her account. I suppose this almost makes sense, as it lets different users of the same machine use different wireless networks. What kind of setup would need this is beyond me.


The new system has been installed since Saturday morning, and we've had no signal drops since then. With the old 802.11b system we'd get dropped connections every few hours, so I'd say that the installation is a roaring success. Now I just have to send in those rebate forms.