个人工具

“UbuntuHelp:WifiDocs/WiFiWithSomeoneElsesRouter”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/WifiDocs/WiFiWithSomeoneElsesRouter}} {{Languages|UbuntuHelp:WifiDocs/WiFiWithSomeoneElsesRouter}} === Introduction === Let's sketch out a hypoth...)
 
第2行: 第2行:
 
{{Languages|UbuntuHelp:WifiDocs/WiFiWithSomeoneElsesRouter}}
 
{{Languages|UbuntuHelp:WifiDocs/WiFiWithSomeoneElsesRouter}}
 
=== Introduction ===
 
=== Introduction ===
 
 
Let's sketch out a hypothetical situation for you. You're a
 
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
 
home desktop user of Ubuntu, and you've just bought a wireless card
第11行: 第10行:
 
on the web - no need to deal with Master mode, or routing, or anything
 
on the web - no need to deal with Master mode, or routing, or anything
 
like that.
 
like that.
 
 
Have you tried [https://help.ubuntu.com/community/WirelessAssistant?action=show WirelessAssistant]? If yes, and it didn't work out, read on for a console solution.
 
Have you tried [https://help.ubuntu.com/community/WirelessAssistant?action=show 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
 
Now, also hypothetically, let's assume that the GUI network
 
configuration tool included with Warty is less than useless; maybe it
 
configuration tool included with Warty is less than useless; maybe it
第20行: 第17行:
 
you try it after getting things running the hard way, it cheerfully
 
you try it after getting things running the hard way, it cheerfully
 
erases the options you finally got to work.  
 
erases the options you finally got to work.  
 
 
So what you're looking for, my hypothetical comrade in
 
So what you're looking for, my hypothetical comrade in
 
arms, is an efficient way to use the text mode utilities to connect to
 
arms, is an efficient way to use the text mode utilities to connect to
 
a wireless network and get on the internet.  
 
a wireless network and get on the internet.  
 
 
=== STEP NEGATIVE ONE ===
 
=== STEP NEGATIVE ONE ===
 
 
Let's assume you've just booted up; X is now
 
Let's assume you've just booted up; X is now
 
running, and you've been kicked to the graphical login screen,
 
running, and you've been kicked to the graphical login screen,
第34行: 第28行:
 
connection. So let's get this fixed up before you personally log in
 
connection. So let's get this fixed up before you personally log in
 
and start up GNOME.  
 
and start up GNOME.  
 
 
Depending on your level of n00bness, you may or may not know how to
 
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
 
deal with virtual TTYs. (Blew my mind when I learned about it.) The idea is that in addition to whatever X is
第46行: 第39行:
 
display, which is where your graphical login is probably living right
 
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.
 
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
 
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
 
either root or an administrative user. While I'm fully aware of the
第57行: 第49行:
 
password is), just preface every command in the coming sections with
 
password is), just preface every command in the coming sections with
 
<code><nowiki>sudo</nowiki></code>.  
 
<code><nowiki>sudo</nowiki></code>.  
 
 
So now you're in text mode and you've got a nice fat prompt to deal
 
So now you're in text mode and you've got a nice fat prompt to deal
 
with.
 
with.
 
 
=== STEP 0 - Are your drivers loaded? ===
 
=== STEP 0 - Are your drivers loaded? ===
 
 
Most everything after this step works with pretty high-level utilities, and will therefore work with any supported
 
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
 
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.
 
MadWifi drivers. Any other adapter, you'll have to do your own forumsurfing.
 
 
Anyway:
 
Anyway:
 
 
Give the command  
 
Give the command  
 
<pre><nowiki>
 
<pre><nowiki>
 
modprobe -l ath*</nowiki></pre>
 
modprobe -l ath*</nowiki></pre>
 
 
This checks the kernel modules to see if the madwifi drivers are
 
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
 
currently running. If they are (as they should be if you installed an
第81行: 第67行:
 
<pre><nowiki>
 
<pre><nowiki>
 
modprobe ath_pci</nowiki></pre>
 
modprobe ath_pci</nowiki></pre>
 
 
which will load up the madwifi drivers and everything they depend
 
which will load up the madwifi drivers and everything they depend
 
on. The modules necessary for this are already in the kernels that
 
on. The modules necessary for this are already in the kernels that
第88行: 第73行:
 
<pre><nowiki>
 
<pre><nowiki>
 
ifconfig</nowiki></pre>
 
ifconfig</nowiki></pre>
 
 
and there should be a network interface called "ath0" or something of the
 
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
 
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.)
 
adapter is called "ath0." If it's something else, just mentally substitute it every time.)
 
 
If it's not in your ifconfig, command  
 
If it's not in your ifconfig, command  
 
<pre><nowiki>
 
<pre><nowiki>
 
ifconfig ath0 up</nowiki></pre>
 
ifconfig ath0 up</nowiki></pre>
 
 
and then check again. If it's still not there, go find someone more
 
and then check again. If it's still not there, go find someone more
 
experienced than me.
 
experienced than me.
 
 
Also, if you ever want to check on the status of your settings partway
 
Also, if you ever want to check on the status of your settings partway
 
through any of these next steps, just command  
 
through any of these next steps, just command  
 
<pre><nowiki>
 
<pre><nowiki>
 
iwconfig ath0</nowiki></pre>
 
iwconfig ath0</nowiki></pre>
 
 
This will give you a lot of wireless-specific information about what's
 
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
 
going on with the interface. And if you're ever in a bind or want to know what anything I'm telling you
第110行: 第90行:
 
<pre><nowiki>
 
<pre><nowiki>
 
man iwconfig</nowiki></pre>
 
man iwconfig</nowiki></pre>
 
 
Now. In order to get your internet up and running, we first need to
 
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
 
tell your interface what network and access point to connect to. For this, it
第116行: 第95行:
 
name) of your network, the channel to operate on, and the encryption
 
name) of your network, the channel to operate on, and the encryption
 
key. This takes us to:
 
key. This takes us to:
 
 
=== STEP 1 - Getting the Goods ===
 
=== STEP 1 - Getting the Goods ===
 
 
The operative command here is <code><nowiki>iwlist ath0 scan</nowiki></code>, but don't do it yet.
 
The operative command here is <code><nowiki>iwlist ath0 scan</nowiki></code>, 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
 
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
第124行: 第101行:
 
<pre><nowiki>
 
<pre><nowiki>
 
iwconfig ath0 channel N</nowiki></pre> where N is your channel. Then do an <code><nowiki>iwlist scan</nowiki></code>, and go to step 2.  
 
iwconfig ath0 channel N</nowiki></pre> where N is your channel. Then do an <code><nowiki>iwlist scan</nowiki></code>, and go to step 2.  
 
 
If you DON'T know, just start with channel 1 (<code><nowiki>iwconfig ath0 channel 1</nowiki></code>), use <code><nowiki>iwlist scan</nowiki></code>, and
 
If you DON'T know, just start with channel 1 (<code><nowiki>iwconfig ath0 channel 1</nowiki></code>), use <code><nowiki>iwlist scan</nowiki></code>, and
 
switch to the next channel if it doesn't find anything. Once you find your network, move on.
 
switch to the next channel if it doesn't find anything. Once you find your network, move on.
 
 
=== STEP 2 - Setting the settings ===
 
=== STEP 2 - Setting the settings ===
 
 
Remember: ESSID, channel, encryption key, access point. You already
 
Remember: ESSID, channel, encryption key, access point. You already
 
have the channel inputted, since you needed it to find your
 
have the channel inputted, since you needed it to find your
第138行: 第112行:
 
iwconfig ath0 ap [your access point's address - six pairs of hex digits, and be sure to include the colons.]
 
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.]</nowiki></pre>
 
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.]</nowiki></pre>
 
 
Okay, you now have the power of knowledge, and your interface is
 
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
 
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.
 
address in order to get on the internets.
 
 
=== STEP 3 - IP me ===
 
=== STEP 3 - IP me ===
 
 
Call  
 
Call  
 
<pre><nowiki>
 
<pre><nowiki>
 
dhclient ath0</nowiki></pre>
 
dhclient ath0</nowiki></pre>
 
 
Since your home network has a router that runs DHCP for all the
 
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
 
computers in the house (which is why you're on this page, RIGHT?), this
第159行: 第129行:
 
things will be working normally, you'll get your weather report,  
 
things will be working normally, you'll get your weather report,  
 
GAIM won't barf, and you can get your email.
 
GAIM won't barf, and you can get your email.
 
 
Unfortunately, you pretty much have to do this every time you
 
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 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.
 
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 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:
 
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
 
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:
 
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
 
Another would allow you to auto-input all the necessary
 
info and obtain an IP address by simply calling it with
 
info and obtain an IP address by simply calling it with
第173行: 第139行:
 
too busy with some other stuff to become one. But if you whip up
 
too busy with some other stuff to become one. But if you whip up
 
something, please edit this page and let me know.
 
something, please edit this page and let me know.
 
 
 
From SoniaHamilton Sat Apr 23 04:57:11 +0100 2005
 
From SoniaHamilton Sat Apr 23 04:57:11 +0100 2005
 
From: Sonia Hamilton
 
From: Sonia Hamilton
第180行: 第144行:
 
Subject: May need to install linux-restricted-modules
 
Subject: May need to install linux-restricted-modules
 
Message-ID: <20050423045711+0100@https://www.ubuntulinux.org>
 
Message-ID: <20050423045711+0100@https://www.ubuntulinux.org>
 
 
You may need to install linux-restricted-modules-* to get wireless going (Atheros chipset, under Hoary)
 
You may need to install linux-restricted-modules-* to get wireless going (Atheros chipset, under Hoary)
 
 
[[category:CategoryLaptop]]
 
[[category:CategoryLaptop]]
 
 
Also try installing netapplet. It may figure out some of this stuff for you.
 
Also try installing netapplet. It may figure out some of this stuff for you.
 
 
----
 
----
 
[[category:CategoryDocumentation]] [[category:CategoryNetworking]] [[category:CategoryCleanup]]
 
[[category:CategoryDocumentation]] [[category:CategoryNetworking]] [[category:CategoryCleanup]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2007年11月30日 (五) 22:26的版本

Introduction

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.

STEP NEGATIVE ONE

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

ifconfig

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

Call

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 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 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: <20050423045711+0100@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.