linux iwconfig工具

iwconfig

注意:radio层不支持该命令,该命令只在协议层使用。

用途:用于设置和操作WLAN接口,方法与ifconfig类似,但是是用于指定802.11设备的操作。

格式:iwconfig interface

   [essid {X|on|off|any}]

   [nwid {N|on|off}]

   [mode {M|Auto}]

   [freq F{k|M|G} ]

   [channel {C|auto|off}]

   [ap {A|off|auto|any}]

   [sens S]

   [nick {NAME}]

   [rate {R|auto|fixed}]

   [rts {RT|auto|fixed|off}]

   [frag {FT|auto|fixed|off}]

   [enc/key {EK|off|open}]

   [power {period P|timeout P|off}]

   [retry {limit R|lifetime R}]

   [txpower {T {mW|dBm} | auto | off}]

   [modu {M|auto}]

   [commit]

参数说明:

essid  #设置ESSID.如果ESSID包含any/on/off则需要在前面加"--"

 例子: #iwconfig ath0 essid any #允许任何ESSID,也就是混杂模式

    #iwconfig ath0 essid "My Network" #设置ESSID为"My Network"

    #iwconfig ath0 essid --"ANY" #设置ESSID为"ANY"

nwid #只用于早期的802.11无线网卡,

#现在的网卡利用ESSID和AP的MAC地址来替换nwid,所以该参数 基本上不用设备

例子:#iwconfig ath0 nwid Jake #设置nwid为Jake

mode #设置无线网卡的工作模式,可以是:

    Ad-hoc: 不带AP的点对点无线网络

    Managed: 通过多个AP组成的网络,无线设备可以在这个网络中漫游

    Master: 设置该无线网卡为AP

    Repeater: 设置为无线网络中继设备,可以转发网络包

    Secondary: 设置为备份的AP/Repeater

    Monitor: 监听模式

    Auto: 由无线网卡自动选择工作模式

例子: #iwconfig ath0 mode Managed

    #iwconfig ath0 mode Master

freq #设置无线网卡的工作频率

例子: #iwconfig ath0 freq 2.422G

channel ["num"|auto]#设置无线网卡的频道

例子: #iwconfig ath0 channel 3

    #iwconfig ath0 channel auto

ap #连接到指定的AP或者无线网络,后面参数可以是AP的MAC地址,

#也可以是iwlist scan出来的标识符。

#在AP环境下WDS客户端模式连接AP或Ad-Hoc模式下客户端连接ad-Hoc网络。

例子:#iwconfig ath0 ap 00:11:22:33:44:55 #也可以是essid

    #iwconfig ath0 ap any    #自动选择最好AP

sens #设置接收灵敏度的下限,在该下限之下,无线网卡会认为该无线网络信号太差,并采取相应操作

    #正的参数认为是百分比数;负的参数表示dBm值。

例子:#iwconfig ath0 sens -85

    #iwconfig ath0 sens 60

nick #别名,一般不设置该参数

例子:#iwconfig ath0 nickname "Other name"

rate #如果无线网卡支持多速率,则可以通过该命令设置工作的速率。

例子:#iwconfig ath0 rate 5.5M

    #iwconfig ath0 rate 5.5M auto #自动选择5.5M以下的速率

    #iwconfig ath0 rate auto

rts #指定RTS/CTS握手方式,使用RTS/CTS握手会增加额外开销,

#但如果在无线网络中有隐藏无线节点或者有很多无线节点时可以提高性能。

例子:#iwconfig ath0 rts 250 #指定该机制的最小包大小为250.

    #iwconfig ath0 rts off #禁用该机制

frag #设置发送数据包的分片大小。

#设置分片会增加额外开销,但在噪声环境下可以提高数据包的到达率。

例子:#iwconfig ath0 frag 256 #设置分片大小为256

    #iwconfig ath0 frag off #关闭分片机制

enc/key #设置无线网卡使用的加密密钥,此处为设置wep加密方式的密钥,

#如果要使用WPA/WPA2需要wpa_supplicant工具包

#如果在密钥之前加"[index]",则只是设置该索引值对应的密钥,并不改变当前的密钥

例子:#iwconfig ath0 key 1111-2222-33

    #iwconifg ath0 key [2] 1111-2222-33

    #iwconfig ath0 key s:password [3] #设置索引值[3]对应的密钥为password

    #iwconfig ath0 key [3]    #使用索引值[3]里面的密钥

    #iwconfig ath0 key open    #开启加密功能

    #iwconfig ath0 key off    #关闭加密功能

power #设置无线网卡的电源管理模式;

    #period 'value'指定唤醒的周期;timeout 'value'指定进入休眠的等待时间。这些值默认单位为秒

例子:#iwconfig ath0 power period 2 #隔2秒唤醒一次

    #iwconfig ath0 power 500m unicast

    #iwconfig ath0 power timeout 300u all

    #iwconfig ath0 power off

    #iwconfig ath0 power min period 2 power max period 4

retry #设置无线网卡的重传机制。

例子: #iwconfig ath0 retry 16

    #iwconfig ath0 retry lifetime 300m #指定最长重试时间为300毫秒,单位也可以是微秒u

    #iwconfig ath0 retry min limit 8 #指定最大重传次数为8次

txpower #如果无线网卡支持多发射功率设定,则使用该参数设定发射,单位为dBm,

    #如果指定为N(毫瓦mW),其转换公式为dBm=30+log(N)

例子:#iwconfig ath0 txpower 15

    #iwconfig ath0 txpower 30mW

    #iwconfig ath0 txpower auto #指定无线自动选择发射功率

    #iwconfig ath0 txpower off #关闭发射单元

modu #指定网卡的调制方式

例子: #iwconfig ath0 modu 11g

    #iwconfig ath0 modu CCK OFDMa

    #iwconfig ath0 modu auto

commit #提交所有的参数修改给无线网卡驱动。一般不需使用到。