| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision |
| zh:docs:guide-user:network:wifi:atheroswds [2019/08/22 02:28] – [LuCI] biaji | zh:docs:guide-user:network:wifi:atheroswds [2019/08/22 10:06] – [使用SSH] biaji |
|---|
| 自从2.6内核使用后,大多数OpenWrt加入了对AP-to-STA WDS模式的无线驱动支持,用于将两个或以上的设备借助无线网桥组成一个统一的广播域。 | 自从2.6内核使用后,大多数OpenWrt加入了对AP-to-STA WDS模式的无线驱动支持,用于将两个或以上的设备借助无线网桥组成一个统一的广播域。 |
| |
| With this configuration you will be able to wirelessly connect a remote wireless OpenWrt device (acting as the wireless station) to a local wireless OpenWrt point (acting as the wireless access point) and the wired devices connected to both devices will be on the same network and broadcast domain. Other wireless client devices can continue to connect to the wireless access point as before. | 经此配置后,您可以将远程无线OpenWrt设备(作为无线基站)以无线连接至一个本地无线OpenWrt接入点(作为无线接入点)。由此实现所有以有线或无线方式连接至两个路由的设备均处于同一网络和广播域中。其它无线客户端仍可以像以前一样连接至无线接入点。 |
| |
| The method below is a layer 2 transparent bridge. All broadcast packets (such as DHCP requests) will be sent in both directions over the wireless bridge and the original source MAC address of the wired devices on both sides are preserved even over the bridge. The wiki article [[doc/howto/clientmode]] has technical background on how this is accomplished. | 以下方式为一个二层透明网桥。所有的广播包(如DHCP请求)将经由无线网桥双向发送,并在传输中保留其原始的源MAC地址不变。维基上的文章[[https://oldwiki.archive.openwrt.org/zh-cn/doc/howto/clientmode|clientmode]]描述了其实现原理。 |
| |
| ===== 配置 ===== | ===== 配置 ===== |
| === 无线接入点 === | === 无线接入点 === |
| |
| Connect to the router that will serve as the wireless access point over SSH. This is the device that connects to the internet or the main network using a wired connection. Ensure that the device is already set up as a normal wireless access point with a SSID, channel selection, WPA2 encryption as desired, etc. and that normal wireless clients can connect to it fine. | 通过SSH连接至无线接入点。此设备使用网线连接至因特网或主网络。请确认此设备已经设置为拥有SSID、无线通道和WPA2加密的普通无线接入点并可以供无线接入的客户端正常使用。 |
| |
| Only one change is needed from a normal wireless access point configuration. | 对于普通的无线接入点来说,仅需要进行一项配置变更。 |
| |
| Once logged in, edit the [[docs:guide-user:network:wifi:basic|/etc/config/wireless]] file. In the existing ''wifi-iface'' section that is being used, add a line with ''option wds '1'''. Note that there may be multiple ''wifi-iface'' sections in this file, especially if the router is a dual band device, in which case you need to ensure that you're editing the correct section. | 登录后,编辑[[docs:guide-user:network:wifi:basic|/etc/config/wireless]]文件。在使用中的已有的''wifi-iface''段落,添加一行:''option wds '1'''。请注意,双频路由的对应文件中可能有多处''wifi-iface''段,您需要确保更改了正确的段落。 |
| |
| Once that is done, save the file and reboot the device to restart all settings. | 完成后,保存文件并重启设备以启用新设置。 |
| |
| Normal wireless clients should be able to connect to the wireless access point exactly as they did before and access the Internet. | 普通无线客户端应当跟从前一样可以连接至无线接入点并访问因特网。 |
| |
| This is an example from /etc/config/wireless on the access point device: | 以下为无线接入点设备上的示例/etc/config/wireless文件: |
| |
| <code> | <code> |
| </code> | </code> |
| |
| After rebooting, the "ifconfig" command should show a new device named something like "wlan.staN" (where N is a number) in addition to the base "wlan0" wireless interface device. (**Note:** when tested on Barrier Breaker, there was no new interface created, neither on the AP nor on the STA, despite WDS working properly.) | 重启后,"ifconfig"命令将在原有"wlan0"接口设备的基础上,额外显示一个名字类似"wlan.staN"(N为数字)的设备(**注意:** 在Barrier Breaker上进行测试时,不论接入点还是基站都没有创建这个新接口,但WDS还是工作的很正常。) |
| |
| The new wlan.staN interface WILL NOT be bridged by default with the originating wlan interface if that interface is not itself part of a bridge, | 如果原有的wlan接口不是网桥的一部分的话,新的wlan.staN接口默认*不会*被桥接。 |
| If in your setup the AP interface is not already part of a bridge you will need to create a new bridge interface and associate only the AP wlan interface to it. In this case hostapd will automatically add any new wlan.staN interface to the bridge. | 如果您设置的AP接口目前还不是网桥的一部分的话,您必须新建一个网桥接口,并将其关联至接入点wlan接口。这样hostapd才会自动将wlan.staN接口添加至网桥。 |
| |
| === The remote wireless station === | === 远端无线终端 === |
| |
| Initially connect to the router that will server as remote wireless station using an Ethernet cable. If you haven't already done so, [[docs:guide-user:installation:generic.flashing|install openwrt]] and [[docs:guide-quick-start:walkthrough_login|setup the password]]. SSH into the station. | 首先,使用网线连接至作为远程无线基站使用的路由。如果还没有进行[[docs:guide-user:installation:generic.flashing|安装openwrt]]和[[docs:guide-quick-start:walkthrough_login|设置密码]],则需要先进行。然后用SSH连接至基站。 |
| |
| The first step is preparing the device for the bridging. | 第一步:为桥接准备设备。 |
| |
| If this is a new OpenWrt setup, a DHCP server is enabled on the lan interface of the device by default. This needs to be disabled before the device is connected to the production network (assuming the production network already has DHCP set up). To do so, edit the [[docs:guide-user:base-system:dhcp|/etc/config/dhcp]] file. Find the ''config dhcp 'lan''' section and add the line ''option ignore '1''' to this section. This will disable the DHCP server on the lan interface. (The lan DHCP section will look like the wan DHCP section, as the DHCP server is already disabled on the wan interface by default.)[On Chaos Calmer 15.05 / LuCI (git-15.248.30277-3836b45), I had to disable the DHCP6 server as well, by changing ''option dhcpv6 'server''' to ''option dhcpv6 'disabled'''. MariusMatutiae] | 如果是首次配置OpenWrt,设备的lan接口默认会启用DHCP服务。在设备连接至生产环境网络之前,需要禁用它(假设生产环境网络已经配置了DHCP服务):编辑[[docs:guide-user:base-system:dhcp|/etc/config/dhcp]]文件,找到''config dhcp 'lan'''段落,并在其中添加一行:''option ignore '1'''。这将在lan接口上禁用DHCP服务器。(lan DHCP段与wan DHCP段看起来很类似,只是wan接口默认禁用了DHCP服务。)[在Chaos Calmer 15.05 / LuCI (git-15.248.30277-3836b45)上, 我还要将''option dhcpv6 'server'''改为''option dhcpv6 'disabled'''以禁用DHCP6服务。 --MariusMatutiae] |
| |
| Following this, reconfigure the lan interface to have another address than the default static IP assignment of 192.168.1.1. Edit the [[docs:guide-user:base-system:basic-networking|/etc/config/network]] file. Set the IP to an another address from the same subnet. For example 192.168.1.2. After rebooting the router, remember to access the console & config via the new IP addess. [Now that I rebooted the router with its dhcp server disabled, I had to temporarily set my PC's IP manually in order to access the router and continue this setup process. --Steve Newcomb] | 然后,要将lan接口默认配置的静态IP 192.168.1.1改为其它地址。编辑[[docs:guide-user:base-system:basic-networking|/etc/config/network]]文件。将IP设置为同一子网的其它地址,比如192.168.1.2。然后重启路由。记得用新IP地址访问并进行配置。[因为在前面禁用了DHCP服务,我不得不手动给我的PC设置一个临时IP,以访问路由并继续配置过程。 --Steve Newcomb] |
| |
| Alternatively, you may try to let the router itself to fetch an IP address via DHCP from the AP, but that may leave router inaccessible if the WDS connection does not work and that STA router does not reach the AP with DHCP. If you want to try that: in the ''lan'' section, remove the static IP configuration and reconfigure the interface to use DHCP. This is an example: | 或者,你也可以让路由从访问点通过DHCP获取一个地址,但如果WDS无法按预期工作,或者基站路由无法访问接入点的DHCP服务,可能会导致路由无法访问。方法为:在''lan''段落中,移除静态IP地址配置并将接口设置为使用DHCP,示例如下: |
| |
| <code> | <code> |
| </code> | </code> |
| |
| __**NOTE:**__ LAN interface can stay static ip but need to disable dhcp server for LAN interface. If set LAN interface to get ip from dhcp server then you have to search remote router ip each time you reboot it. | __**注意:**__ LAN接口可以保持静态ip,但必须禁用dhcp服务。如果将LAN接口设置为由dhcp服务获取ip的话,则每次启动时,都会查找远端路由ip。 |
| |
| Once those steps are completed, we can setup the actual wireless link. | 当上述步骤完成后,我们就可以开始设置wifi连接了。 |
| |
| Edit the [[docs:guide-user:network:wifi:basic|/etc/config/wireless]] file. In the ''radio0'' section, make sure that the wireless settings match the values in the access point. | 编辑[[docs:guide-user:network:wifi:basic|/etc/config/wireless]]文件。在''radio0''段,需确保无线设置与接入点的对应设置值保持一致。 |
| |
| Further down in the same file, modify the ''wifi-iface'' section to include the desired SSID to which to connect (the same one as on the access point) and ensure WDS is enabled by setting this value to 1. | 同一文件的下面一点,修改''wifi-iface''段,加入想要连接至的SSID(即接入点的SSID),并确认WDS已启用:其值设置为1。 |
| |
| This is an example from /etc/config/wireless on the wireless client bridge device. The specific options may be different depending on the hardware but the SSID, channel, encryption type and password must match the access point, and WDS mode must be turned on. | 以下是一个无线客户端桥接设备的/etc/config/wireless文件示例。某些选项根据硬件不同可能会有所差异,但SSID、无线通道、加密类型必须与接入点保持一致。而且WDS模式必须开启。 |
| |
| <code> | <code> |
| </code> | </code> |
| |
| See the [[docs:guide-user:network:wifi:encryption|Configure WiFi encryption]] for pointer on how to specify encryption and keys. | 参阅[[docs:guide-user:network:wifi:encryption|配置无线密码]]以获取更多密码和密钥配置的信息。 |
| |
| Disconnect the device from the wired network and reboot the device without any wired connection. | 将设备由有线网络断开,并在保持没有有线连接的情况下重启。 |
| |
| The device should boot and automatically connect wirelessly to the access point. **Wait until the client bridge device associates with the access point. This can take 1-2 minutes for the association to happen.** Once this has happened, the **wired interface (e.g. eth0)** should succeed in getting a DHCP address through the new wireless bridge connection. Note that the wireless interface itself on the remote client bridge device does not get an IP address as it is now acting as a transparent bridge. | 设备重启后将自动连入接入点的无线网络。**客户段网桥设备启动并连入接入点需要花费1-2分钟,需要等待这个过程结束。** 然后,**有线接口(比如eth0)**将通过无线桥接连接成功获取DHCP地址。注意,此时远端客户端网桥设备的无线网络自身却不会获取到IP地址,因为它作为透明网桥被使用。 |
| |
| Any //wired devices// connected via Ethernet to the LAN ports on the remote client bridge device should now be transparently bridged into the main network over the wireless link. | 通过LAN端口连接至远端客户端网桥设备的//有线设备//此时已经经由无线连接透明网桥至主网络了。 |
| |
| **For wireless connection, one additional step is required:** | **无线连接,还需最后一步:** |
| |
| Create a //new wireless interface//. You can simply add it in LuCi -> WiFi, or create a new //wifi-iface// section in /etc/config/wireless. Copy all the values from the existing interface, but make two changes: use mode 'ap' instead of 'sta' and leave out the WDS option or set it to 0. SSID and key may be the same as with the host SSID for transparent roaming, but they can also be different. As long as you connect this new interface to //lan//, which is the default, your other wireless devices connecting through this AP will also be seen as part of the big network. | 创建一个//新的无线接口//。您可以直接在LuCi -> 无线 中创建,或在/etc/config/wireless中创建一个新的//wifi-iface//段。从既有的接口配置复制所有配置项,并进行如下两项改动:用'ap'替换'sta',并删除WDS配置项或将其值设置为0.SSID和密码可以与主路由保持一致以实现透明漫游,但也可以设为不同的。将此接口依照默认值连接至//lan//,您的其余连接至此接入点的无线设备就自动成为了网络的一部分。 |
| |
| ==== LuCI ==== | ==== LuCI ==== |
| |
| 最后,仍需按照上述''For wireless connection, one additional step is required''步骤执行,直至完毕。 | 最后,仍需按照上述''For wireless connection, one additional step is required''步骤执行,直至完毕。 |
| ===== Old Stuff ===== | ===== 老物件 ===== |
| |
| Relevant configuration files: | 相关配置文件: |
| |
| * [[docs:guide-user:network:wifi:basic|/etc/config/wireless]] | * [[docs:guide-user:network:wifi:basic|/etc/config/wireless]] |
| |
| |
| Multiple //WDS Stations// can connect to a single //WDS Access Point//. | 多 //WDS Stations// 可连接至一个 //WDS Access Point//. |
| |
| * On the Access Point, add ''option wds 1'' to the existing ''wifi-iface'' section and proceed with configuring SSID, channel, encryption etc. | * 在接入点上,在现存的''wifi-iface''部分添加''option wds 1'',并配置SSID、通道、安全认证等。 |
| * On the Client, set ''option mode'' to ''sta'' and add ''option wds 1'' to the ''wifi-iface'' section. Disable the DHCP server, e.g. by adding ''option ignore 1'' for LAN interface in /etc/config/dhcp. | * 在客户端将''option mode'' 设置为''sta''并将''option wds 1''添加至''wifi-iface''部分。禁用DHCP服务器:比如,在/etc/config/dhcp中针对LAN接口增加''option ignore 1''。 |
| *To create a repeater, add a WDS Access Point along with the WDS Station on the client,(with the same ssid and key, or not). Don't forget to add the newly created AP to the LAN firewall Zone. | * 创建中继器:添加WDS接入点并在客户端创建WDS终端。(可以用一样的SSID和key,也可以不用)。不要忘记将新创建的接入点添加至LAN防火墙区域。 |
| |
| On MAC80211 OpenWRT use 4 address (option wds 1) (with ap or sta mode) and not repeater mode. See also [[http://linuxwireless.org/en/users/Documentation/iw#Setting_up_a_WDS_peer]] | 在MAC80211上OpenWRT使用了4地址格式(option wds 1) (with ap or sta mode)而不是中继器模式。参见[[http://linuxwireless.org/en/users/Documentation/iw#Setting_up_a_WDS_peer]] |
| |