跳转至: 导航, 搜索

<<Include(Tag/Unsupported)>> <<Include(Tag/StyleCleanup)>> <<Include(Tag/Deletion)>>


Let's sketch out a hypothetical situation for you. You're a home desktop user of Ubuntu, and you've just bought a wireless card based on an Atheros chipset (say, for example, a D-Link DWL-G520) in order to connect to an already-running wireless network in your house. Maybe you moved into a new place, the housemates have an Apple Airport Express running, and all you want to do is politely get on the web - no need to deal with Master mode, or routing, or anything like that. Have you tried WirelessAssistant? If yes, and it didn't work out, read on for a console solution. Now, also hypothetically, let's assume that the GUI network configuration tool included with Warty is less than useless; maybe it binds up for several minutes, pretends to confirm some sort of decision, and then proceeds to not work. Maybe if you try it after getting things running the hard way, it cheerfully erases the options you finally got to work. So what you're looking for, my hypothetical comrade in arms, is an efficient way to use the text mode utilities to connect to a wireless network and get on the internet.


Let's assume you've just booted up; X is now running, and you've been kicked to the graphical login screen, probably the one that has good-looking people looking up at you. Chances are that a lot of the stuff in your (the user's) GNOME session (weather report, GAIM, whatever) is reliant on an active internet connection. So let's get this fixed up before you personally log in and start up GNOME. Depending on your level of n00bness, you may or may not know how to deal with virtual TTYs. (Blew my mind when I learned about it.) The idea is that in addition to whatever X is doing right now, you have access to 6 virtual text-mode screens that use no graphics at all. These are not the terminal program you use from within X (although you use them similarly). If you're oldschool: they act like your basic DOS box. (If you're really oldschool: you've skipped this paragraph. Forgive me.) In order to switch between these virtual TTYs, you use ctrl-alt-f[X], where X is a number between 1 and 6 inclusive. (So, ctrl-alt-f1 is your first virtual TTY, ctrl-alt-f2 is your second one, etc etc.) Ctrl-alt-f7 is the default graphical display, which is where your graphical login is probably living right now, and where your GNOME session is going to be in a few minutes. Ctrl-alt-f[>7] are other graphical displays that you can spawn new X sessions on. Don't worry about that right now; in fact, pretend you didn't read it. Anyway, go to one of these, probably the first one, and log in as either root or an administrative user. While I'm fully aware of the nuances of the holy war surrounding the root account in Ubuntu circles, I personally prefer to have a superuser login running if I'm going to be issuing string after string of administrative commands. I log out after I'm done with the job, I promise. At any rate, your mileage varies as always, and if you're using a regular account (and ESPECIALLY if you don't know what the root account is or what its password is), just preface every command in the coming sections with sudo. So now you're in text mode and you've got a nice fat prompt to deal with.

STEP 0 - Are your drivers loaded?

Most everything after this step works with pretty high-level utilities, and will therefore work with any supported wireless adapter whose Linux drivers use the Wireless Extensions. Since I'm only working with an Atheros-chipset-based card, I'm just going to do a brief outline of how to make sure your system is doing okay with the MadWifi drivers. Any other adapter, you'll have to do your own forumsurfing. Anyway:

Give the command
modprobe -l ath*

This checks the kernel modules to see if the madwifi drivers are currently running. If they are (as they should be if you installed an Atheros-based card and turned the computer back on; Ubuntu's pretty smart about this), you'll see two lines, one of which ends with "ath_pci.ko" and one of which ends with "ath_hal.ko". If neither of these is there,

go ahead and command
modprobe ath_pci

which will load up the madwifi drivers and everything they depend on. The modules necessary for this are already in the kernels that Ubuntu ships by default. Now just to make sure everything's shiny,

tell it to

and there should be a network interface called "ath0" or something of the sort. If so, we're good. (For the rest of this, I'm assuming your adapter is called "ath0." If it's something else, just mentally substitute it every time.)

If it's not in your ifconfig, command
ifconfig ath0 up

and then check again. If it's still not there, go find someone more experienced than me. Also, if you ever want to check on the status of your settings partway

through any of these next steps, just command
iwconfig ath0

This will give you a lot of wireless-specific information about what's going on with the interface. And if you're ever in a bind or want to know what anything I'm telling you

means, hit up
man iwconfig

Now. In order to get your internet up and running, we first need to tell your interface what network and access point to connect to. For this, it needs to know the MAC address of your access point, the ESSID (the name) of your network, the channel to operate on, and the encryption key. This takes us to:

STEP 1 - Getting the Goods

The operative command here is iwlist ath0 scan, but don't do it yet. This scans for any networks that are broadcasting their ESSID (which most basic home wireless networks are) and reports back their info. The vital piece of intel that tends to get glossed over here is that the scan can only get info for networks using the channel the adapter is

CURRENTLY TUNED TO. If you already know the channel your local wireless access point operates on, you are solid; just type
iwconfig ath0 channel N
where N is your channel. Then do an iwlist scan, and go to step 2.

If you DON'T know, just start with channel 1 (iwconfig ath0 channel 1), use iwlist scan, and switch to the next channel if it doesn't find anything. Once you find your network, move on.

STEP 2 - Setting the settings

Remember: ESSID, channel, encryption key, access point. You already have the channel inputted, since you needed it to find your network's other info. Now that you've sucessfully scanned, you have all the

rest of the info you need, and just have to input it:
iwconfig ath0 essid [your essid]
iwconfig ath0 ap [your access point's address - six pairs of hex digits, and be sure to include the colons.]
iwconfig ath0 key [your key - if you don't know the hex digits and want to use the password you used when setting up the router, enter the key as s:yourencryptionkey; otherwise enter it as the traditional big nasty string of hex digits.]

Okay, you now have the power of knowledge, and your interface is talking to your access point. Samba and stuff should theoretically be working now; I wouldn't know, I can't tell Samba from tango and have never learned how to work with it. ANYWAY. So now you just need an IP address in order to get on the internets.

STEP 3 - IP me

dhclient ath0

Since your home network has a router that runs DHCP for all the computers in the house (which is why you're on this page, RIGHT?), this command will ask it to assign you an IP address. Hopefully, this is all you need; it'll tell you what your assigned local IP address is (note that this isn't what other computers on the internet are going to parse your IP address as; it's just used for internal purposes within your network), when it renews, and some other info about what's going on with the whole process. Assuming you don't get an obvious fail message, you're now on the web. Go ahead and log out of your text mode session (just type "logout"), switch back to your graphical login screen (ctrl-alt-f7, remember?), and log in as usual... hopefully, things will be working normally, you'll get your weather report, GAIM won't barf, and you can get your email. Unfortunately, you pretty much have to do this every time you reboot. I think I've got some clues as to how to make it remember all the relevant info, but I'm too busy to figure it out completely right now, and besides, doing it, write my essay this way only takes a minute or two if you write down the info it's going to want every time and post it on the wall by your workspace. But if you know what files to edit and what the syntax is, feel free to chime in with a page edit. ALSO. If one were a wizard at Bash scripting, it seems like it ought to be trivial to create a pair of scripts, of which: One would scan for networks on all available channels, parse iwlist's output, cache the relevant info to a file, and output a list of valid nearby ESSIDs to stdout, and: Another would allow you to auto-input all the necessary info and obtain an IP address by simply calling it with a valid nearby ESSID as the argument; it would then check the scan-cache file for that ESSID and call iwconfig a few times using the information essay writing companies associated with said ESSID, asking for a passphrase as necessary. I am not such a wizard, and am too busy with some other stuff to become one. But if you whip up something, please edit this page and let me know. From SoniaHamilton Sat Apr 23 04:57:11 +0100 2005 From: Sonia Hamilton Date: Sat, 23 Apr 2005 04:57:11 +0100 Subject: May need to install linux-restricted-modules Message-ID: <[email protected]https://www.ubuntulinux.org> You may need to install linux-restricted-modules-* to get wireless going (Atheros chipset, under Hoary) Also try installing netapplet. It may figure out some of this stuff for you.