WIFI iwlist/iwconfig/iw/wpa_supplicant

1、iwlist

用于对/proc/net/wireless文件进行分析,得出无线网卡相关信息

~ # iwlist --help
Usage: iwlist [interface] scanning [essid NNN] [last]
              [interface] frequency 
              [interface] channel 
              [interface] bitrate 
              [interface] rate 
              [interface] encryption 
              [interface] keys 
              [interface] power 
              [interface] txpower 
              [interface] retry 
              [interface] ap 
              [interface] accesspoints 
              [interface] peers 
              [interface] event 
              [interface] auth 
              [interface] wpakeys 
              [interface] genie 
              [interface] modulation 

# iwlist wlan0 scanning 搜索当前无线网络

# iwlist wlan0 frequen  显示频道信息

# iwlist wlan0 rate  显示连接速度

# iwlist wlan0 power  显示电源模式

# iwlist wlan0 txpower 显示功耗

# iwlist wlan0 retry  显示重试连接次数(网络不稳定查看)

# iwlist wlan0 ap 显示热点信息

# iwlist --help 显示帮助信息

# iwlist --version 显示版本信息

2、iwconfig  

系统配置无线网络设备或显示无线网络设备信息。iwconfig 命令类似于ifconfig命令,但是他配置对象是无线网卡,它对网络设备进行无线操作,如设置无线通信频段

~ # iwconfig --help
Usage: iwconfig [interface]
                interface essid {NNN|any|on|off}
                interface mode {managed|ad-hoc|master|...}
                interface freq N.NNN[k|M|G]
                interface channel N
                interface bit {N[k|M|G]|auto|fixed}
                interface rate {N[k|M|G]|auto|fixed}
                interface enc {NNNN-NNNN|off}
                interface key {NNNN-NNNN|off}
                interface power {period N|timeout N|saving N|off}
                interface nickname NNN
                interface nwid {NN|on|off}
                interface ap {N|off|auto}
                interface txpower {NmW|NdBm|off|auto}
                interface sens N
                interface retry {limit N|lifetime N}
                interface rts {N|auto|fixed|off}
                interface frag {N|auto|fixed|off}
                interface modulation {11g|11a|CCK|OFDMg|...}
                interface commit


auto 自动模式

essid 设置ESSID

nwid 设置网络ID

freq 设置无线网络通信频段

chanel 设置无线网络通信频段

sens 设置无线网络设备的感知阀值

mode 设置无线网络设备的通信设备

ap 强迫无线网卡向给定地址的接入点注册

nick<名字> 为网卡设定别名

rate<速率> 设定无线网卡的速率

rts<阀值> 在传输数据包之前增加一次握手,确信信道在正常的

power 无线网卡的功率设置

3、iw

iw是一种新的基于 nl80211 的用于无线设备的CLI配置实用程序。它支持最近已添加到内核所有新的驱动程序。采用无线扩展接口的旧工具iwconfig已被废弃,强烈建议切换到 iw 和 nl80211。Linux内核的其余部分,iw 仍处于开发阶段。功能被随时添加。 iw 的唯一文档就是此页和“iw help”的输出。 请帮助扩大这个页面。

有一个页面列出iwconfig和iw的用例:替换 iwconfig.

# iw help    # 帮助

# iw list    # 获得所有设备的功能,如带宽信息(2.4GHz,和5GHz),和802.11n的信息

# iw dev wlan0 scan    # 扫描

# iw event    # 监听事件

# iw dev wlan0 link    # 获得链路状态

# iw wlan0 connect foo    # 连接到已禁用加密的AP,这里它的SSID是foo

# iw wlan0 connect foo 2432  # 假设你有两个AP SSID 都是 foo ,你知道你要连接的是在 2432 频道

# iw wlan0 connect foo keys 0:abcde d:1:0011223344    # 连接到使用WEP的AP

# iw dev wlan1 station dump    # 获取station 的统计信息

# iw dev wlan1 station get     # 获得station对应的peer统计信息

# iw wlan0 set bitrates legacy-2.4 12 18 24    # 修改传输比特率

# iw dev wlan0 set bitrates mcs-5 4    # 修改tx HT MCS的比特率

# iw dev wlan0 set bitrates mcs-2.4 10

# iw dev wlan0 set bitrates mcs-5    # 清除所有 tx 比特率和设置的东西来恢复正常

# iw dev  set txpower  []   #设置传输功率

# iw phy  set txpower  []   #设置传输功率

# iw dev wlan0 set power_save on  #设置省电模式

# iw dev wlan0 get power_save  #查询当前的节电设定

# iw phy phy0 interface add moni0 type monitor  #添加一个 monitor 接口

4、wpa_supplicant

        wpa_supplicant 是跨平台的 WPA 请求者程序(supplicant),支持 WEP、WPA 和 WPA2(IEEE 802.11i / RSN )。

可以在桌面、笔记本甚至嵌入式系统中使用。       

        连接到加密无线网络的第一步是让 wpa_supplicant 获取 WPA 认证者的认证。为此, wpa_supplicant 必须进行配置以使其能够向认证者提交认证信息。一旦完成认证,就可以正常连接网络,并通过 iproute2 手工获取 IP 地址;或者使用 systemd-networkd 或 dhcpcd之类的网络管理程序,通过配置一个接口然后通过 DHCP 自动获取 IP 地址。

        发现了什么?sta使用iwconfig命令只能连接无密码的AP热点,要连接使用WEP、WPA等加密的AP,就需要借助wpa_supplicant!

       当然,wpa_supplicant也有其他功能:

usage:
  wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] [-g<global ctrl>] \
        -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-p<driver_param>] \
        [-b<br_ifname>] [-f<debug file>] [-e<entropy file>] \
        [-o<override driver>] [-O<override ctrl>] \
        [-N -i<ifname> -c<conf> [-C<ctrl>] [-D<driver>] \
        [-p<driver_param>] [-b<br_ifname>] ...]

drivers:
  athr = Atheros Linux driver
options:
  -b = optional bridge interface name
  -B = run daemon in the background
  -c = Configuration file
  -C = ctrl_interface parameter (only used if -c is not)
  -i = interface name
  -d = increase debugging verbosity (-dd even more)
  -D = driver name (can be multiple drivers: nl80211,wext)
  -e = entropy file
  -g = global ctrl_interface
  -K = include keys (passwords, etc.) in debug output
  -t = include timestamp in debug messages
  -h = show this help text
  -L = show license (BSD)
  -o = override driver parameter for new interfaces
  -O = override ctrl_interface parameter for new interfaces
  -p = driver parameters
  -P = PID file
  -q = decrease debugging verbosity (-qq even less)
  -v = show version
  -W = wait for a control interface monitor before starting
  -N = start describing new interface
example:
  wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf

猜你喜欢

转载自blog.csdn.net/dxpqxb/article/details/84842211