目录
iw是一个新的为无线网络设备配置工具,基于nl80211命令行配置工具集.它支持大多数最新添加到kernel中的驱动.
iw仍在继续开发中,新的特性将被添加.目前只有这一个页面文档,请帮助扩展它.
这个页面列出iwconfig和iw的使用实例:iw正在替换iwconfig.
发布版的iw可以访问http://linuxwireless.org/download/iw/.
另外,你也可以使用git: http://git.sipsolutions.net/iw.git.
libnl >= libnl1
libnl-dev >= libnl-dev-1
使用iw需要有libnl, 第一个工作版本是1.0 pre8, Generic Netlink, nl80211于它.大多数操作系统预装1.1 如果你的操作系统预装的libnl版本不对,你需要重新下载编译libnl(http://git.kernel.org/?p=libs/netlink/libnl.git;a=summary).
Just enter
iw help
在你的命令行输入以上命令,查看命令是否被支持.
用以下命令获取所有设备能力,如频段信息(2.4 GHz, and 5 GHz),以及802.11n信息:
iw list
iw dev wlan0 scan
iw event
当调试时,用以下命令对查看auth/assoc/deauth/disassoc frames很有用
iw event -f
有时候定时信息也很有用:
iw event -t
你可以使用以下命令确定你是否连接到一个AP和最近一次传送速率.
例如当关联到一个非802.11n的信息如下:
iw dev wlan0 link Connected to 04:21:b0:e8:c8:8b (on wlan0) SSID: attwifi freq: 2437 RX: 2272 bytes (18 packets) TX: 232 bytes (3 packets) signal: -57 dBm tx bitrate: 36.0 MBit/s
当关联到一个802.11n AP的例子:
iw dev wlan0 link Connected to 68:7f:74:3b:b0:01 (on wlan0) SSID: tesla-5g-bcm freq: 5745 RX: 30206 bytes (201 packets) TX: 4084 bytes (23 packets) signal: -31 dBm tx bitrate: 300.0 MBit/s MCS 15 40Mhz short GI
未连接到AP的例子:
iw dev wlan0 link Not connected.
如果你未连接到一个AP,以上打印会出现.连接到一个AP,你可以使用iw connect如果连接需求为:
如果你需要使用WPA或者WPA2加密连接到AP,那么你必须使用到wpa_supplicant.
你可以使用iw连接到以下类型的AP:
如果你在一个比较忙的网络中,很容易掉线,你需要重发命令验证.如果你不想这样你只需要使用wpa_supplicant,它可以自动重连
如果你想自己处理掉线,你可以使用以下命令.
连接到SSID为foo未加密的网络命令如下:
iw wlan0 connect foo
加入你有两个SSID为foo的AP,并且你想连接的是频率2432的,你可以使用以下命令:
iw wlan0 connect foo 2432
连接到使用WEP的AP,可以使用:
iw wlan0 connect foo keys 0:abcde d:1:0011223344
获取站点统计数据如发送和接收字节数,最近传送比特率,可以使用以下命令:
$ iw dev wlan1 station dump Station 12:34:56:78:9a:bc (on wlan0) inactive time: 304 ms rx bytes: 18816 rx packets: 75 tx bytes: 5386 tx packets: 21 signal: -29 dBm tx bitrate: 54.0 MBit/s
如果你想获取与你通信站点的统计信息:
sudo iw dev wlan1 station get <peer-MAC-address>
<peer-MAC-address> 是你AP的MAC地址.
你可以设置一个指定的比特率如:
iw wlan0 set bitrates legacy-2.4 12 18 24
设置MCS速率暂不支持.
你可以设置发送功率任意Phy的任意接口.
iw dev <devname> set txpower <auto|fixed|limit> [<tx power in mBm>] iw phy <phyname> set txpower <auto|fixed|limit> [<tx power in mBm>]
开启节能模式:
sudo iw dev wlan0 set power_save on
对于mac80211驱动意味着允许动态节能.
查询当前节能模式设置:
iw dev wlan0 get power_save
有以下模式支持:
查看这些的描述,请阅读modes documentation.
添加monitor接口例子:
iw phy phy0 interface add moni0 type monitor
你可以用其他的接口名替换moni0,也可以用其他类型替换monitor,你需要用你的硬件PHY名字替换掉phy0 (除非你热插拔或者重加载modules,通常phy0都是正确的.) 如果你的udev未配置正确,你新创建的虚拟接口将被更名,使用ip link查看所有接口
假如你想设置802.11n你需要制定信道宽度(20 or 20/40MHz) :
iw dev <devname> set freq <freq> [HT20|HT40+|HT40-]
或者
iw phy <phyname> set freq <freq> [HT20|HT40+|HT40-]
你可以指定信道替换频率:
iw phy <phyname> set channel <channel> [HT20|HT40+|HT40-] iw dev <devname> set channel <channel> [HT20|HT40+|HT40-]
创建一个新的模式接口使用:
iw phy phy0 interface add wlan10 type managed
当使用hostapd时,AP模式自动加入.
你可以定制你创建接口的类型.在终端用户系统在调试方面很有用.例如你想利用mac80211中的monitor接口向用户空间传送额外数据.我们想帮助用户在不影响性能的前提下抓取出一些数据可以使用以下命令:
iw dev wlan0 interface add fish0 type monitor flags none
你可以新开一个会话窗口使用tcpdump:
tcpdump -i fish0 -s 65000 -p -U -w /tmp/fishing.dump
The nice thing about these type of alternative monitor interfaces is you can further extend radiotap even with vendor extensions to add more data to radiotap to help debug device specific features.
Keep in mind this requires drivers to honor mac80211's flag requests strictly, so drivers like ath5k and ath9k which still enable flags based on operation mode need to be fixed to take advantage of this.
The following are flags you can specify:
iw dev moni0 del
There is a dedicated section for virtual vif support, see the iw vif page.
iw dev wlan0 set freq 2412 [HT20|HT40+|HT40-]
iw dev wlan0 set channel 1 [HT20|HT40+|HT40-]
iw reg set alpha2
Where "alpha2" is the ISO/IEC 3166 alpha2 country code. The information used and set comes from our regulatory infrastructure.
You can also use the latest wpa_supplicant (as of 0.6.7) now to change your regulatory domain, to do so just add a "COUNTRY=US" entry into your configuration for example.
You may add a mesh interface to drivers that support Mesh Point operation. Mesh Point interfaces have a mesh_id parameter which may be up to 32 bytes long. For example, to add an interface "mesh0" to device phy0 with mesh_id "mymesh",
iw phy phy0 interface add mesh0 type mp mesh_id mymesh
Mesh Point interfaces, by default, are configured on Channel 1. Mesh Point operation begins when the interface is brought up. In the default configuration, Mesh Point interfaces will automatically detect and attempt to create Peer Links with other Mesh Points (peers) having the same mesh ID. Use the station list and station statistics to see the peer list and Peer Link status.
After sending traffic (ex: pinging another mesh node), you may wish to see a list of Mesh Paths:
iw dev mesh0 mpath dump
Please see the open80211s.org HOWTO for further details on Mesh Point related commands and their output, as well as more examples. iw also provides commands for advanced Mesh Point configuration. These are documented in the Advanced Tinkering section of the open80211s HOWTO.
To create a WDS peer you will first need to create an interface of WDS type, and then set the peer:
iw phy phy0 interface add wds0 type wds iw dev wds0 set peer <MAC address>
In order for this to work the driver must implement the cfg80211 callback set_wds_peer(). mac80211 implements this callback, so the respective mac80211 driver would just need to support WDS type interfaces. What WDS will do is replace the first address on the 802.11 header with the peer address when TXing frames. Instead of using WDS though you may want to consider using 4-address mode described below if you have control over the software running on the AP and respective clients/peers connected.
在一些解决方案中使用AP和多客户端很有用In some situations it might be useful to run a network with an Access Point and multiple clients, but with each client bridged to a network behind it. For this to work, both the client and the AP need to transmit 4-address frames, containing both source and destination MAC addresses.
Linux无线对AP和STA支持4-address模式但需要明确定义.如果AP和STA模式分别支持,所有的mac80211驱动都支持4-address模式.
在AP端,你可以开启支持4-address模式,通过在4-address模式中配置使用AP VLAN使其隔离.正是这个APVLAN将只限制客户端,这个客户端将被作为它接口传送的目的端,不管目的MAC地址是否在包头中. 这种模式的优势相对WDS模式是容易配置,不需要对每个MAC地址静态配置.
创建接口并允许4-address模式使用:
iw phy phy0 interface add moni0 type managed 4addr on
当客户端的接口被包含在一个桥接设备中,在运行wpa_supplicant添加-b <bridge_interface>.
在hostapd中在hostapd.conf设置以下标志实现:
wds_sta=1