diff options
Diffstat (limited to 'zh_CN.GB2312/books/handbook/advanced-networking/chapter.sgml')
-rw-r--r-- | zh_CN.GB2312/books/handbook/advanced-networking/chapter.sgml | 289 |
1 files changed, 280 insertions, 9 deletions
diff --git a/zh_CN.GB2312/books/handbook/advanced-networking/chapter.sgml b/zh_CN.GB2312/books/handbook/advanced-networking/chapter.sgml index 6166ca85a8..ad90aa2083 100644 --- a/zh_CN.GB2312/books/handbook/advanced-networking/chapter.sgml +++ b/zh_CN.GB2312/books/handbook/advanced-networking/chapter.sgml @@ -2,7 +2,7 @@ The FreeBSD Documentation Project The FreeBSD Chinese Documentation Project - Original revision: 1.400 + Original revision: 1.403 $FreeBSD$ --> @@ -840,8 +840,8 @@ ath0: mac 7.9 phy 4.5 radio 5.6</screen> <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> up scan</userinput> SSID BSSID CHAN RATE S:N INT CAPS -dlinkap 00:13:46:49:41:76 6 54M 29:0 100 EPS WPA WME -freebsdap 00:11:95:c3:0d:ac 1 54M 22:0 100 EPS WPA</screen> +dlinkap 00:13:46:49:41:76 6 54M 29:3 100 EPS WPA WME +freebsdap 00:11:95:c3:0d:ac 1 54M 22:1 100 EPS WPA</screen> <note> <para>在开始扫描之前, 必须将网络接口设为 <option>up</option>。 @@ -1049,7 +1049,7 @@ ath0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 方法是将前面的 <literal>DHCP</literal> 关键字替换为地址信息。 请务必保持其他用于连接无线访问点的参数:</para> - <programlisting>ifconfig_ath0="inet <replaceable>192.168.1.100</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>your_ssid_here</replaceable>"</programlisting> + <programlisting>ifconfig_ath0="ssid <replaceable>your_ssid_here</replaceable> inet <replaceable>192.168.1.100</replaceable> netmask <replaceable>255.255.255.0</replaceable>"</programlisting> </sect5> <sect4 id="network-wireless-wpa"> @@ -1492,8 +1492,8 @@ ath0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 <para>WEP 可以通过 <command>ifconfig</command> 配置:</para> - <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> inet <replaceable>192.168.1.100</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid my_net \ - wepmode on weptxkey 3 wepkey 3:0x3456789012</userinput></screen> + <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> ssid my_net wepmode on weptxkey 3 wepkey 3:0x3456789012 \ + inet <replaceable>192.168.1.100</replaceable> netmask <replaceable>255.255.255.0</replaceable></userinput></screen> <itemizedlist> <listitem> @@ -1547,7 +1547,7 @@ Associated with 00:13:46:49:41:76</screen> <para>在计算机 <hostid>A</hostid> 上:</para> - <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>freebsdap</replaceable> mediaopt adhoc</userinput> + <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> ssid <replaceable>freebsdap</replaceable> mediaopt adhoc inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable></userinput> &prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable></userinput> ath0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255 @@ -1565,13 +1565,13 @@ Associated with 00:13:46:49:41:76</screen> <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> up scan</userinput> SSID BSSID CHAN RATE S:N INT CAPS - freebsdap 02:11:95:c3:0d:ac 2 54M 19:0 100 IS</screen> + freebsdap 02:11:95:c3:0d:ac 2 54M 19:3 100 IS</screen> <para>在输出中的 <literal>I</literal> 再次确认了 <hostid>A</hostid> 机是以 ad-hoc 模式运行的。 我们只需给 <hostid>B</hostid> 配置一不同的 IP 地址:</para> - <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> inet <replaceable>192.168.0.2</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>freebsdap</replaceable> mediaopt adhoc</userinput> + <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> ssid <replaceable>freebsdap</replaceable> mediaopt adhoc inet <replaceable>192.168.0.2</replaceable> netmask <replaceable>255.255.255.0</replaceable></userinput> &prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable></userinput> ath0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet6 fe80::211:95ff:fed5:4362%ath0 prefixlen 64 scopeid 0x1 @@ -1585,6 +1585,277 @@ Associated with 00:13:46:49:41:76</screen> <para>这样, <hostid>A</hostid> 和 <hostid>B</hostid> 就可以交换信息了。</para> </sect2> + <sect2 id="network-wireless-ap"> + <title>&os; 基于主机的(无线)访问接入点</title> + + <para>&os; 可以作为一个(无线)访问接入点(AP), + 这样可以不必再去买一个硬件 AP 或者使用 ad-hoc 模式的网络。 + 当你的 &os; 机器作为网关连接到另外一个网络的时候将非常有用。</para> + + <sect3 id="network-wireless-ap-basic"> + <title>基本配置</title> + + <para>在把你的 &os; 机器配置成一个 AP 以前, + 你首先需要先在内核配置好对你的无线网卡的无线网络支持。 + 当然你还需要加上你想用的安全协议。想获得更详细的信息, + 请参阅 <xref linkend="network-wireless-basic">。</para> + + <note> + <para>目前还不支持使用 &windows; 驱动和 NDIS + 驱动包装的网卡做为 AP 使用。只有 &os; + 原生的无线驱动能够支持 AP 模式。</para> + </note> + + <para>一旦装载了无线网络的支持, + 你就可以检查一下看看你的无线设备是否支持基于主机的无线访问接入模式 + (通常也被称为 hostap 模式):</para> + + <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> list caps</userinput> +ath0=783ed0f<WEP,TKIP,AES,AES_CCM,IBSS,HOSTAP,AHDEMO,TXPMGT,SHSLOT,SHPREAMBLE,MONITOR,TKIPMIC,WPA1,WPA2,BURST,WME></screen> + + <para>这段输出显示了网卡所支持的各种功能; 其中的关键字 + <literal>HOSTAP</literal> + 表示这块无线网卡能作为一个(无线)访问接入点使用。 + 同时也提到了各种加密算法: WEP,TKIP,WPA2,等等, + 这些信息对于知道在访问接入点上使用何种安全协议非常重要。</para> + + <para>现在这块无线设备在配置了正确的 SSID 和 IP + 地址后进入 hostap 模式了。</para> + + <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> ssid <replaceable>freebsdap</replaceable> mode 11g mediaopt hostap</userinput> inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable></screen> + + <para>再一次用 <command>ifconfig</command> 查看一下 + <devicename>ath0</devicename> 网络接口的状态:</para> + + <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable></userinput> + ath0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 + inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255 + inet6 fe80::211:95ff:fec3:dac%ath0 prefixlen 64 scopeid 0x4 + ether 00:11:95:c3:0d:ac + media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap> + status: associated + ssid freebsdap channel 1 bssid 00:11:95:c3:0d:ac + authmode OPEN privacy OFF txpowmax 38 bmiss 7 protmode CTS burst dtimperiod 1 bintval 100</screen> + + <para><literal>hostap</literal> + 参数说明这个网络接口目前正运行在基于主机的接入访问模式。</para> + + <para>也可以在 <filename>/etc/rc.conf</filename> + 中加入以下这行使得网络界面的配置能够在机器启动的时候自动完成:</para> + + <programlisting>ifconfig_ath0="ssid <replaceable>freebsdap</replaceable> mode 11g mediaopt hostap inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable>"</programlisting> + </sect3> + + <sect3> + <title>不使用认证或加密的(无线)访问接入点</title> + + <para>尽管我们不推荐运行一个不使用任何认证或加密的 AP, + 但这是一个非常简单的检测 AP 是否正常工作的方法。 + 这样配置对于调试客户端问题也非常重要。</para> + + <para>一旦 AP 被配置成了我们前面所展示的那样, + 就可以在另外一台无线机器上初始化一次扫描来找到这个 AP:</para> + + <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> up scan</userinput> +SSID BSSID CHAN RATE S:N INT CAPS +freebsdap 00:11:95:c3:0d:ac 1 54M 22:1 100 ES</screen> + + <para>在客户机上能看到已经连接上了(无线)访问接入点:</para> + + <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> ssid <replaceable>freebsdap</replaceable> inet <replaceable>192.168.0.2</replaceable> netmask <replaceable>255.255.255.0</replaceable></userinput> +&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable></userinput> + ath0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 + inet6 fe80::211:95ff:fed5:4362%ath0 prefixlen 64 scopeid 0x1 + inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255 + ether 00:11:95:d5:43:62 + media: IEEE 802.11 Wireless Ethernet autoselect (OFDM/54Mbps) + status: associated + ssid freebsdap channel 1 bssid 00:11:95:c3:0d:ac + authmode OPEN privacy OFF txpowmax 36 protmode CTS bintval 100</screen> + </sect3> + + <sect3> + <title>使用 WPA 的(无线)访问接入点</title> + + <para>这一段将注重介绍在 &os; (无线)访问接入点上配置使用 + WPA 安全协议。 更多有关 WPA 和配置基于 WPA 无线客户端的细节 + 请参阅 <xref linkend="network-wireless-wpa">。</para> + + <para><application>hostapd</application> + 守护进程将被用于处理与客户端的认证和在启用 WPA + (无线)访问接入点上的密钥管理。</para> + + <para>接下来,所有的配置操作都将在作为 AP 的 &os; 机器上完成。 + 一旦 AP 能够正确的工作了,便把如下这行加入 + <filename>/etc/rc.conf</filename> 使得 + <application>hostapd</application> + 能在机器启动的时候自动运行:</para> + + <programlisting>hostapd_enable="YES"</programlisting> + + <para>在配置 <application>hostapd</application> 以前, + 请确保你已经完成了基本配置中所介绍的步骤 <xref + linkend="network-wireless-ap-basic">。</para> + + <sect4> + <title>WPA-PSK</title> + + <para>WPA-PSK 旨在为没有认证服务器的小型网络而设计的。</para> + + <para>配置文件为 + <filename>/etc/hostapd.conf</filename> file:</para> + + <programlisting>interface=ath0 <co id="co-ap-wpapsk-iface"> +debug=1 <co id="co-ap-wpapsk-dbug"> +ctrl_interface=/var/run/hostapd <co id="co-ap-wpapsk-ciface"> +ctrl_interface_group=wheel <co id="co-ap-wpapsk-cifacegrp"> +ssid=freebsdap <co id="co-ap-wpapsk-ssid"> +wpa=1 <co id="co-ap-wpapsk-wpa"> +wpa_passphrase=freebsdmall <co id="co-ap-wpapsk-pass"> +wpa_key_mgmt=WPA-PSK <co id="co-ap-wpapsk-kmgmt"> +wpa_pairwise=CCMP TKIP <co id="co-ap-wpapsk-pwise"></programlisting> + + <calloutlist> + <callout arearefs="co-ap-wpapsk-iface"> + <para>这一项标明了访问接入点所使用的无线接口。</para> + </callout> + + <callout arearefs="co-ap-wpapsk-dbug"> + <para>这一项设置了执行 <application>hostapd</application> + 时候显示相关信息的详细程度。 + <literal>1</literal> 表示最小的级别。</para> + </callout> + + <callout arearefs="co-ap-wpapsk-ciface"> + <para><literal>ctrl_interface</literal> 这项给出了 + <application>hostapd</application> + 存储与其他外部程序(比如 &man.hostapd.cli.8;) + 通信的域套接口文件路径。这里使用了默认值。</para> + </callout> + + <callout arearefs="co-ap-wpapsk-cifacegrp"> + <para><literal>ctrl_interface_group</literal> + 这行设置了允许访问控制界面文件的组属性 + (这里我们使用了 <groupname>wheel</groupname> 组)。</para> + </callout> + + <callout arearefs="co-ap-wpapsk-ssid"> + <para>这一项是设置网络的名称。</para> + </callout> + + <callout arearefs="co-ap-wpapsk-wpa"> + <para><literal>wpa</literal> 这项表示启用了 WPA + 而且指明要使用何种 WPA 认证协议。 + 值 <literal>1</literal> 表示 AP 将使用 WPA-PSK。</para> + </callout> + + <callout arearefs="co-ap-wpapsk-pass"> + <para><literal>wpa_passphrase</literal> + 这项包含用于 WPA 认证的 ASCII 密码。</para> + + <warning> + <para>通常使用从丰富的字母表生成足够长度的强壮密码, + 以不至于被轻易的猜测或攻击到。 + </warning> + </callout> + + <callout arearefs="co-ap-wpapsk-kmgmt"> + <para><literal>wpa_key_mgmt</literal> + 这行表明了我们所使用的密钥管理协议。 + 在这个例子中是 WPA-PSK。</para> + </callout> + + <callout arearefs="co-ap-wpapsk-pwise"> + <para><literal>wpa_pairwise</literal> + 这项表示(无线)访问接入点所接受的加密算法。 + 在这个例子中,TKIP(WPA) 和 CCMP(WPA2) 密码都会被接受。 + CCMP 密码是除 TKIP 外的另一种选择, + CCMP 一般作为首选密码; + 仅有在 CCMP 不能被使用的环境中选择 TKIP。</para> + </callout> + </calloutlist> + + <para>接下来的一步就是运行 + <application>hostapd</application>:</para> + + <screen>&prompt.root <userinput>/etc/rc.d/hostapd forcestart</userinput></screen> + + <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable></userinput> + ath0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2290 + inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255 + inet6 fe80::211:95ff:fec3:dac%ath0 prefixlen 64 scopeid 0x4 + ether 00:11:95:c3:0d:ac + media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap> + status: associated + ssid freebsdap channel 1 bssid 00:11:95:c3:0d:ac + authmode WPA2/802.11i privacy MIXED deftxkey 2 TKIP 2:128-bit txpowmax 36 protmode CTS dtimperiod 1 bintval 100</screen> + + <para>现在客户端能够连接上运行的(无线)访问接入点了, + 更多细节可以参阅 <xref linkend="network-wireless-wpa">。 + 查看有哪些客户连接上了 AP 可以运行命令 + <command>ifconfig <replaceable>ath0</replaceable> list + sta</command>。</para> + </sect4> + </sect3> + + <sect3> + <title>使用 WEP 的(无线)访问接入点</title> + + <para>我们不推荐使用 WEP 来设置一个(无线)访问接入点, + 因为没有认证的机制并容易被破解。 一些历史遗留下的无线网卡仅支持 + WEP 作为安全协议, 这些网卡仅允许搭建不含认证或 WEP + 协议的 AP。</para> + + <para>在设置了正确的 SSID 和 IP 地址后,无线设备就可以进入 + hostap 模式了:</para> + + <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> ssid <replaceable>freebsdap</replaceable> wepmode on weptxkey 3 wepkey 3:0x3456789012 mode 11g mediaopt hostap \ + inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable></userinput></screen> + + <itemizedlist> + <listitem> + <para><literal>weptxkey</literal> 表示传输中使用哪一个 + WEP 密钥。 这个例子中用了第3把密钥(请注意密钥的编号从 + <literal>1</literal>开始)。 + 这个参数必须设置以用来加密数据。</para> + </listitem> + + <listitem> + <para><literal>wepkey</literal> 表示设置所使用的 WEP + 密钥。 它应该符合 <replaceable>index:key</replaceable> + 这样的格式。 如果没有指定 index,那么默认值为 + <literal>1</literal>。 + 这就是说如果我们使用了除第一把以外的密钥, + 那么就需要指定 index。</para> + </listitem> + </itemizedlist> + + <para>再使用一次 <command>ifconfig</command> 命令查看 + <devicename>ath0</devicename> 接口的状态:</para> + + <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable></userinput> + ath0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 + inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255 + inet6 fe80::211:95ff:fec3:dac%ath0 prefixlen 64 scopeid 0x4 + ether 00:11:95:c3:0d:ac + media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap> + status: associated + ssid freebsdap channel 1 bssid 00:11:95:c3:0d:ac + authmode OPEN privacy ON deftxkey 3 wepkey 3:40-bit txpowmax 36 protmode CTS dtimperiod 1 bintval 100</screen> + + <para>现在可以从另外一台无线机器上初始化一次扫描来找到这个 + AP 了:</para> + + <screen>&prompt.root; <userinput>ifconfig <replaceable>ath0</replaceable> up scan</userinput> +SSID BSSID CHAN RATE S:N INT CAPS +freebsdap 00:11:95:c3:0d:ac 1 54M 22:1 100 EPS</screen> + + <para>现在客户机能够使用正确的参数(密钥等) + 找到并连上(无线)访问接入点了, + 更多细节请参阅<xref linkend="network-wireless-wep">。</para> + </sect3> + </sect2> + <sect2> <title>故障排除</title> |