[wiki]WiFiHowto

参与到Ubuntu的翻译中来
回复
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

[wiki]WiFiHowto

#1

帖子 oneleaf » 2005-07-22 14:29

Wi-Fi WLAN wireless networking information
Getting Started

Obviously before you set up the wireless card on your computer you will need to become familiar with the basics of wireless and set up your wireless Router/Access Point. A good place to start is with the router documentation which often has a introduction to Wi-Fi. You will also probably have to look at the documentation to set up the Router. You may want to have a look at [WWW] the Wi-Fi entry on Wikipedia or [WWW] the technology overview of the Linux Wlan HOWTO however these are both a bit technical, it would be good if someone could find a simple newbie document and add it here.

First thing you'll need to do is get the [WWW] wireless-tools package (see SynapticHowto).

Some Wi-Fi Cards work out of the box, specifically the ones with the Orinoko, Prism2 or Atheros chipsets. If your card does not work out of the box, [SetupNdiswrapperHowto]. Some prism cards may not work out of the box however.

Set up your Wireless Router as an 'open' network. I.e. Turn off all security such as WAP in Mac Address restriction. However you should set your Network Name (ESSID) in your Router.
Using Graphical User Interface Tools

To see if your card is working goto Computer->System Configuration->Networking and see if your wireless network card is listed. Usually your wireless card is named wlan0 or ath0, depending on your chipset and the driver you are using. To determine what your wireless network card interface is called, you have to type iwconfig in a terminal (open up a Terminal Window by clicking Applications->System Tools->Terminal). If your card does not appear it has not been recognised either as the chipset needs additonal support from something like the [SetupNdiswrapperHowto] mentioned previously.

The next step is configuring your Card. Select the wireless network card entry (wlan0 or ath0) in the Networking window to check that wireless is working and click on Properties. This is where you set your Network Name. Normaly Configuration can be left as Automatic (DHCP). Chances are you have set up your wireless router as a DHCP Server, if not do so (refer to Router documentation). Click on OK.

Select the eth0 network and click on Deactivate button (if you have one - basicaly deactivate all Networks). Then select wlan0 and click on the Activate button. You should end up with the checkbox under Active for wlan0 checked and the others not checked. You can now fire up a web browser and see if you can browse the web. Alternativly the best way of checking if you have a working internet connection is to use ping. ping simply checks if a domain exists. Type

ping google.com

and you should get a line periodicaly saying 'Unknown host' if your internet conection is down or a line every second of so telling you how long it took to reach the host. To test only the network in case the DNS is down, you can use ping with the -n option, but then you have to give it a numeric IP address. A simple to remember one is

ping -n 4.2.2.2

Using the command Line

If you can browse the web your card is set up and working. If not we can try doing it another way. Start a Terminal Window and type

ifconfig

This will list your networks. The standard network is normaly called eth0. Stop this network by typing

sudo ifdown eth0

do this for all networks except for 'lo'. then start your wireless network by typing

sudo ifup wlan0

Check this has worked by typing ifconfig and if all is well try browsing the Web/ping. If it is not try the following

iwconfig wlan0 mode managed
iwconfig wlan0 channel 11
iwconfig wlan0 essid networkname

mode managed is what you want if you are connecting to a wireless router. The channel and esidd will have to be set the same as your router.

You have your network working but it is an open/unsecure network. Refer to your Router documentation to find out how to set up a secure network. Eatch Network card (Either wired or wireless) has a unique number called a Mac Address. Most wireless routers allow you to restrict the Mac Addresses that can connect to them. To find out your Mac Address type

ifconfig wlan0

This is listed as the first line after !HWaddr.
Encryption

It is also good to set up encryption (we will use WEP encryption as it is well supported in Ubuntu) as Mac Address restricting can be circumnavigated. Firstly you will have to set up your router to use WEP encryption. This the rest of this paragraph is a bit vage as a different routers work slightly differently but should give you an idea. Refur to your router manual but WEP setup should be under something like wireless->security on the web interface of your router. Generaly you then enable WEP security and choose a key size. The bigger the better but the example here is using 64 bit (sometimes refured to as 40 bit) keys. Generely you can then type a Passphrase (a password but you should use a few words next to eatch other). Generaly you then click on something like Generate and several keys (normally 4) are created. One of them will be marked as the default key, this is the one we will use.

There is a field under Network Name (ESSID) in Computer->System Configuration->Networking->(wlan0) Properties. The idea is that you put your key here but I cant get it working. What I have manages to get working is typing

iwconfig wlan0 key FEFEFEFEFE

Where FEFEFEFEFE is the WEP key in Hexadecimal. Hexadecimel uses 0-F rather than 0-9 (This is base 16 with A representing 10 all the way up to F = 15 and then 10 representing 16.). This is the way all keys are specified. You should then be able to browse the web/ping. Not entirly sure but it seems sometimes you have to wait a minute or so for it to start working.
Adding it to /etc/network/interfaces

/etc/network/interfaces is the file where your network interfaces are defined, eth0 being the standard wired interface. To make the wireless network come up when you start your computer put # in front of 'auto eth0' (to stop it automaticaly starting) and add something like the following lines.

auto wlan0
iface wlan0 inet dhcp
name Wireless LAN card
wireless_essid MYNETWOTK
wireless_key FEFEFEFEFE
wireless_channel 11
wireless_mode managed

I have written a small script to have my laptop automatically pick a WLAN network of several configured. It uses the wireless utils to scan for known/open networks on "ifup interface". The script wlan-scan.sh looks like this:

#!/bin/sh

IFACE=$1

ip link set $IFACE up

SCAN=$( \
iwlist $IFACE scan 2>&1 | grep -v "^$IFACE" | grep -v "^$" | \
sed -e "s/^\ *//" \
-e "s/^Cell [0-9]\+ - /#/" \
-e "s/^#Address: /#AP=/" \
-e "s/^Quality:\([0-9]\+\)\/.*$/QUALITY=\1/" \
-e "s/^.*Channel \([0-9]\+\).*$/CHANNEL=\1/" \
-e "s/^ESSID:/ESSID=/" \
-e "s/^Mode:/MODE=/" \
-e "s/^Encryption key:/ENC=/" \
-e "s/^[^#].*:.*//" | \
tr "\n#" "|\n" \
)

ip link set $IFACE down

which=""
while read glob scheme; do
AP=""; QUALITY=""; CHANNEL=""; ESSID=""; MODE=""; ENC=""
for i in $SCAN ; do
for j in $(echo $i | sed -e "s/|/ /g" ) ; do
case $j in
AP=*)
AP=${j#AP=}
;;
QUALITY=*)
QUALITY=${j#QUALITY=}
;;
CHANNEL=*)
CHANNEL=${j#CHANNEL=}
;;
ESSID=*)
ESSID=${j#ESSID=}
;;
MODE=*)
MODE=${j#MODE=}
;;
ENC=*)
ENC=${j#ENC=}
;;
esac
done

case "$AP,$ESSID,$ENC,$MODE,$CHANNEL" in
$glob)
echo $scheme
exit 0
;;
esac
done
done

exit 1

and is used with the mapping primitive of the interfaces file.

Mine looks like this:

mapping wlan0

script /path/to/wlan-scan.sh
# Accesspoint,"ESSID",Encryption,Mode,Channel
map 00:FE:FE:FE:00:00,"MY_NET",*,*,* wlan0-home
map *,"COMPANY",on,Master,* wlan0-office
map *,*,off,Master,* wlan0-open

iface wlan0-home inet dhcp
wireless-essid HOMENET
wireless-mode managed
wireless-enc FEFEFEFEFEFE

iface wlan0-office inet dhcp
wireless-essid COMPANY
wireless-mode managed
wireless-enc s:Secret_password

# This is a fallback, selected for all unencrypted WLANs
iface wlan0-open inet dhcp
wireless-essid ANY
wireless-mode managed

Please report if this does not work for you (or if it does;-).
Wi-Fi roaming

Wi-Fi is most useful on a laptop. Taking your laptop everywhere also involves changing networks quite often. It is quite bothersome having to change this everytime you want to hook up to a different network.

To solve this a number of programs have been developped that automagically bring up your wireless network interface when a network has been detected. The older encryption method WEP has been superceded by WPA. For setting up WPA, see the the description of setting up wpa_supplicant in the WPAHowto. However wpa_supplicant still has issues with some drivers. Especially roaming between old WEP networks isn't well supported with wpa_supplicant, therefor has a look at the older [WWW] waproamd.

Some people might prefer a script to do network switching, have a look at:

*

[WWW] Getwifi

Other people might prefer a GUI tool to do network switching though, have a look at:

*

[WWW] !WiFi Radar
*

[WWW] Gnome Net Applet
*

[WWW] Red Hat's Network Manager


https://wiki.ubuntu.com/WiFiHowto
当净其意如虚空,远离妄想及诸取,令心所向皆无碍
头像
Lucia
帖子: 29
注册时间: 2005-07-15 21:19

#2

帖子 Lucia » 2005-07-22 15:20

这一篇我认领了
Things change......
头像
Lucia
帖子: 29
注册时间: 2005-07-15 21:19

#3

帖子 Lucia » 2005-07-22 20:37

Wi-Fi WLAN 无线网络信息
开始进行


显然在你的电脑上设置无线网卡之前你需要熟悉一下无线网络的基本知识,同时设定你的无线网络的路由器或接驳点。最好是从路由器的文档入手,它通常有一份关于Wi-Fi的介绍。你同时也很有可能需要参考这份文档来设置路由器。你也许需要看一下网络上关于Wi-Fi登陆到Wikipedia的信息或如何设置Linux Wlan的技术概观。这两个都有点专业,但是如果有人能够找到一份简单的网络新手文件加在这里是最好不过了。

第一件你将需要做的事情是从网上获取无线网络工具包(参见SynapticHowto)。

有一些Wi-Fi网卡是外置工作的,特别是有Orinoko,Prism2或者Atheros芯片集的那些网卡。如果你的卡并不是外置工作的[SetupNdiswrapperHowto]。当然有一些prism网卡也许是不能外置工作的。

将你的无线路由器设置成“开放式”网络。关掉所有的安全限制,比如WAP硬件地址限制。当然,你必须在你的路由器中设置你自己的网络名称(ESSID)。
使用图形用户界面工具。

查看你的网卡是否在工作,转到Computer(电脑)->System Configuration(系统配置)->Networking(网络),然后看是否你的无线网卡在其中。一般来说你的无线网卡的名称是wlan0或者ath0,这个取决于你的芯片集和你采用的驱动程序。为了决定你的无线网卡接口的称谓,你需要在终端输入iwconfig(通过打开Applications/应用程序->System Tools/系统工具->Terminal/终端来打开一个终端)。如果你的网卡没有出现在其中,那么它要么是没有被识别,要么是芯片集需要附加的支持,比如之前的[SetupNdiswrapperHowto]提到的那样。

下一步就是配置你的网卡。在网络窗口选择无线网卡登陆(wlan0或者ath0)以确认无线网络正在工作,点击Properties(属性)。这里是你设置你的网络名称的地方。通常是配置是默认自动配置(DHCP)。如果你没有这么做,有可能你也已经将你的无线路由器设置成了DHCP服务器(参见路由器文档)。点OK。

选择eth0网络然后点击Deactivate(禁用)按钮(如果你有这个按钮的话-基本上禁用所有的网络)。接着选择wlan0,然后点击Activate(启用)按钮。在结束的时候应该是Active(启用)下面的检查栏中关于wlan0的被选中而其他的没有被选中。你现在可以打开一个浏览器来看看是否你可以浏览网页。还有另一个最好的检查你是否拥有一个正在工作的网络连接的方法就是使用ping。ping仅仅是检查一个域名是否存在。输入

ping google.com

然后如果你的网络连接不通你会收到一条周期性的信息“Unknown host”(未知的主机),或者每隔一秒一条信息以告知你需要多久可以到达主机。万一DNS不通,仅仅测试网络,你可以ping -n 选项,但是这时你需要提供一个数字的IP地址。一个很容易记的是

ping -n 4.2.2.2

使用命令行

如果你可以浏览网页,你的网卡已经设置了并且正在工作。如果不是,我们可以尝试从另一个途径达到这个目的。开一个终端窗口然后输入

ifconfig

这个将会列出你的网络。标准的网络通常是叫eth0。输入以下指令来停止这个网络

sudo ifdown eth0

除了“lo”,对所有的网络做这样的操作。然后输入以下指令以开始你的无线网络

sudo ifup wlan0

输入ifconfig以确认这个已经工作了,如果所有的都好了,尝试浏览网页或者ping。如果不行,尝试以下的命令

iwconfig wlan0 mode managed
iwconfig wlan0 channel 11
iwconfig wlan0 essid networkname


mode managed是如果你在连接一个无线路由器时所需要的。channel和esidd需要设置的跟你的路由器一致。

你使你的网络工作,但是它是一个开放的网络或者说是一个不安全的网络。参考你的路由器文档以查找到如何设置一个安全的网络。每一个网卡(不论有线还是无线)有一个唯一的数字,这个数字叫硬件地址。大多数无线路由器允许你限制那些可以连接它们的硬件地址。输入以下命令以查找你的硬件地址类型

ifconfig wlan0

这个是!HWaddr(这个词我看不明白,是否有可能是原文有些错误,因为我在翻译的过程中也遇到了一些拼写的错误,请大家指点一下)下面的第一行。

加密

设置加密同样是有好处的(我们将使用WEP加密,因为Ubuntu能很好的支持它),因为硬件地址限制是可以被循环的。第一,你需要设置你的路由器以使用WEP加密。这篇文章剩下的部分 ,因为虽然不同的路由器工作有着细微的区别,但是仍需要提供一个概念。参考你的路由器手册,但是WEP的设置应该像你路由器的网络接口上的一些类似wireless(无线)->security(安全)的东西。一般在这个时候你能够使用WEP安全并且选择一个key size。越大越好,但是在这里的例子是使用的64bit(有时候会提到40bit)keys。通常你可以键入一个passphrase(一个密码,但是你必须使用一些紧靠在一起的单词)。一般来讲这时候再点击类似Generate(生成),several keys(常规是4)就被创建了。其中之一将会被标记为默认key,这个就是我们将要用到的。

Computer(电脑)->System Configuration(系统配置)->Networking(网络)->(wlan0)properties(属性)。这个想法是你将你的key填在这里,但是我没法让它工作,我所能做的使它工作的办法就是输入

iwconfig wlan0 key FEFEFEFEFE

FEFEFEFEFE的地址是WEP key的十六进制表达。十六进制将0-F而不是0-9(这是以16为基数,A代表10然后一直以此种方式到F,F代表15,10代表16)。所有的key都是以这种方法来说明的。你接下来应该可以浏览网页或者ping。虽然并不是完全确认,但是有时候好像你需要等它一分钟左右开始工作。
将它添加到/etc/network/interfaces

/etc/network/interfaces是定义你的网络接口的文件。eth0是标准的有线网络接口。为了使无线网络在你开启你的电脑时出现,赋# in front of 'auto eth0'(以此来阻止它自动的开始运行)同时添加类似于以下内容的几条指令。

auto wlan0
iface wlan0 inet dhcp
name Wireless LAN card
wireless_essid MYNETWOTK
wireless_key FEFEFEFEFE
wireless_channel 11
wireless_mode managed


我已经编写了一个小的脚本来使我的膝上型电脑自动的选择几个配置过的WLAN网络。它使用无线utils(这个词我不太明白它的意思,是否是原文有误)在“ifup interface”上来搜索已知的或者开放的网络。脚本wlan-scan.sh类似以下内容:

#!/bin/sh

IFACE=$1

ip link set $IFACE up

SCAN=$( \
iwlist $IFACE scan 2>&1 | grep -v "^$IFACE" | grep -v "^$" | \
sed -e "s/^\ *//" \
-e "s/^Cell [0-9]\+ - /#/" \
-e "s/^#Address: /#AP=/" \
-e "s/^Quality:\([0-9]\+\)\/.*$/QUALITY=\1/" \
-e "s/^.*Channel \([0-9]\+\).*$/CHANNEL=\1/" \
-e "s/^ESSID:/ESSID=/" \
-e "s/^Mode:/MODE=/" \
-e "s/^Encryption key:/ENC=/" \
-e "s/^[^#].*:.*//" | \
tr "\n#" "|\n" \
)

ip link set $IFACE down

which=""
while read glob scheme; do
AP=""; QUALITY=""; CHANNEL=""; ESSID=""; MODE=""; ENC=""
for i in $SCAN ; do
for j in $(echo $i | sed -e "s/|/ /g" ) ; do
case $j in
AP=*)
AP=${j#AP=}
;;
QUALITY=*)
QUALITY=${j#QUALITY=}
;;
CHANNEL=*)
CHANNEL=${j#CHANNEL=}
;;
ESSID=*)
ESSID=${j#ESSID=}
;;
MODE=*)
MODE=${j#MODE=}
;;
ENC=*)
ENC=${j#ENC=}
;;
esac
done

case "$AP,$ESSID,$ENC,$MODE,$CHANNEL" in
$glob)
echo $scheme
exit 0
;;
esac
done
done

exit 1


而且是和底层映射的接口文件一起使用。

我的看起来跟这个类似:


mapping wlan0

script /path/to/wlan-scan.sh
# Accesspoint,"ESSID",Encryption,Mode,Channel
map 00:FE:FE:FE:00:00,"MY_NET",*,*,* wlan0-home
map *,"COMPANY",on,Master,* wlan0-office
map *,*,off,Master,* wlan0-open

iface wlan0-home inet dhcp
wireless-essid HOMENET
wireless-mode managed
wireless-enc FEFEFEFEFEFE

iface wlan0-office inet dhcp
wireless-essid COMPANY
wireless-mode managed
wireless-enc s:Secret_password

# This is a fallback, selected for all unencrypted WLANs
iface wlan0-open inet dhcp
wireless-essid ANY
wireless-mode managed

Please report if this does not work for you (or if it does;-).
Wi-Fi roaming


Wi-Fi对于膝上型电脑而言是最方便的。带着你的膝上型电脑云游四方同样意味着频繁的更换网络。每次当你要寻找一个不同的网络时都要改变设置是比较令人烦恼的。

为了解决这个问题,发展了很多程序,这些程序在一个网络被探测到的时候可以自动的调出你的网络接口。比较老一些的加密方法WEP已经被WPA取代了。如何设置WPA可以参考WPAHowto(如何设置WPA)种的关于设置wpa_supplicatiot的描述。不过wpa_supplicatiot仍然有一些关于驱动程序的争论。特别是徘徊在旧的WEP网络在wpa_supplicant中并没有获得很好的支持,因此还需参考网络上旧一些的waproamd。

有些人也许会喜欢一个切换网络的脚本,请参看:

*

[WWW] Getwifi

尽管其他人也许会喜欢用GUI工具来实现网络切换,请参看:

*

[WWW] !WiFi Radar
*

[WWW] Gnome Net Applet
*

[WWW] Red Hat's Network Manager


https://wiki.ubuntu.com/WiFiHowto
Things change......
头像
Lucia
帖子: 29
注册时间: 2005-07-15 21:19

#4

帖子 Lucia » 2005-07-22 21:00

这个是我第一次翻译,有翻译的不太贴切的地方请大家指点一下,谢谢 :P
Things change......
头像
gnix_oag
帖子: 1994
注册时间: 2005-05-19 18:38
来自: 湖南永州
联系:

#5

帖子 gnix_oag » 2005-07-22 22:49

强啊

我来这里这么久了都不敢啊

因为我的水平........
头像
Lucia
帖子: 29
注册时间: 2005-07-15 21:19

#6

帖子 Lucia » 2005-07-22 23:16

我是新人,第一次尝试帮论坛翻译,感觉真激动 :D
Things change......
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

#7

帖子 oneleaf » 2005-07-28 11:46

当净其意如虚空,远离妄想及诸取,令心所向皆无碍
头像
millenniumdark
论坛版主
帖子: 4159
注册时间: 2005-07-02 14:41
系统: Ubuntu 14.04 (Kylin)
联系:

#8

帖子 millenniumdark » 2006-07-31 0:42

Lucia 写了:我是新人,第一次尝试帮论坛翻译,感觉真激动 :D
和我第一次一样
头像
millenniumdark
论坛版主
帖子: 4159
注册时间: 2005-07-02 14:41
系统: Ubuntu 14.04 (Kylin)
联系:

#9

帖子 millenniumdark » 2006-07-31 0:46

businesslcp
帖子: 13
注册时间: 2008-01-14 10:58

#10

帖子 businesslcp » 2008-01-22 11:32

呵呵,大家一起齐心协力:)
谢谢您的翻译,翻译的非常不错!
希望以后如果有“这个是!HWaddr(这个词我看不明白,是否有可能是原文有些错误,因为我在翻译的过程中也遇到了一些拼写的错误,请大家指点一下)下面的第一行。”
类似的问题的话希望能够集中总结一下,这样字好找些:)
补充:
1、HWaddr 计算机硬件地址(一般常指MAC地址)
2、DHCP 动态主机配置协议(自动分配和获得IP地址用的)
3、它使用无线utils(这个词我不太明白它的意思,是否是原文有误)在“ifup interface” 可以理解为无线支持工具包
回复