Moving from one wireless network to another has traditionally been a pain under Linux. Here's how you can simplify this aspect of mobile computing using your wireless adapter and NetworkManager.
One of the coolest things about having a laptop that's Wi-Fi-enabled is being able to go from place to place and freely associate with any hotspots that may be around. If you do this often, it really changes the way you work, as places like your local coffee shop have the potential to become your office. If you use a Windows or Mac OS-equipped laptop, bouncing from place to place isn't much of a challenge: you simply open up your computer, it tells you what access points are around, you click on one to associate with that network, and you're off and running. Under Linux, however, that's been problematic, as there haven't been any tools that make Wi-Fi easy...until now.
Ubuntu supports a good number of wireless cards and adapters out of the box; simply plug in your adapter and it should be recognized automatically (if not, see "Get Proprietary Wireless Cards Working" [Hack #41]). To verify your adapter is recognized, open a terminal window and issue the following command:
iwconfiglo no wireless extensions. eth0 no wireless extensions. eth1 IEEE 802.11g ESSID:"Its A Grind" Mode:Managed Frequency:2.412 GHz Access Point: 00:06:B1:14:C7:49 Bit Rate=24 Mb/s Tx-Power=20 dBm Retry limit:7 RTS thr:off Fragment thr:off Power Management:off Link Quality=53/100 Signal level=-69 dBm Noise level=-87 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:41 Invalid misc:0 Missed beacon:16
If you see output similar to what's above mentioning an IEEE interface, then your card is recognized by Ubuntu and you can either use the built-in networking tools (System→Administration→Networking) to manage it, or proceed on with this hack to install NetworkManager. If you don't see a wireless card listed there, then you'll need to follow the instructions in "Get Proprietary Wireless Cards Working" [Hack #41] to get your card working using ndiswrapper.
The folks over at Red Hat have come up with a tool that makes Wi-Fi management as easy as a couple of mouse clicks. The tool's called NetworkManager (see Figure 4-9), and it's a GNOME applet that sits in your notification area. NetworkManager will not only manage Wi-Fi connections, it'll automatically hook up your laptop with a wired connection when you plug in an Ethernet cable.
NetworkManager cannot manage any cards that have entries in /etc/network/interfaces. If you've added your network card to that file, make sure you remove it before you start working with NetworkManager.
From the NetworkManager web site:
A laptop user should never need to use the command line or configuration files to manage their network; it should "Just Work" as automatically as possible and intrude as little as possible into the user's workflow. NetworkManager attempts to make networking invisible. When moving into areas you've been before, NetworkManager automatically connects to the last network the user chose to connect to. Likewise, when back at the desk, NetworkManager will switch to the faster, more reliable wired network connection.
So, now that we've whetted your appetite, let's get NetworkManager installed. First, you've got to meet a couple prerequisites:
You must have a wireless Ethernet adapter, either built-in or PCMCIA.
NetworkManager works only with DHCP-assigned addresses. If you must have a static IP address, work with your DHCP administrator to get a unique DHCP reservation, or you'll need to use another tool (such as System→Administration→Networking).
Let's get NetworkManager installed and working. It's surprisingly easy.
First, apt-get the packages. From a terminal, run:
sudo apt-get install network-manager-gnome
This will install both the NetworkManager daemon (as a dependency) and the nm-applet that sits in the GNOME notification area. You'll notice that the NetworkManger service gets started when the installation completes. All that remains is to verify that nm-applet has been added to your session and to reboot the system, since changes to HAL (the hardware abstraction layer) were made when the packages installed.
To verify that NetworkManager's nm-applet program has been added to your autostartup sessions, click on the System Menu in your menu bar, select Preferences, and then click on Sessions. Click on Startup Programs, as shown in Figure 4-10. You should see an nm-applet listing there. If there isn't one, you can add it by clicking on Add and then by filling out the dialog.
Now all that remains for you to do is to reboot. Once you've rebooted and logged in to your machine, you'll see the NetworkManager icon in your notification area. If you're plugged into Ethernet, you should see a little "plug" icon. To use Wi-Fi, click on the NetworkManager icon and select the access point with which you want to associate. If the Wi-Fi access point requires an encryption code, you'll be prompted to enter it. Also, if this is your first time using the GNOME keyring services, you'll be prompted to select a keyring password. The GNOME keyring caches all the WEP keys for you, so all you need to remember is your GNOME keyring password.