supplicant
概述
wpa_supplicant是wifi客户端(client)加密认证工具,和iwconfig不同,wpa_supplicant支持wep、wpa、wpa2等完整的加密认证,而iwconfig只能支持wep。
和wpa_supplocant相对应的,ap端的加密认证工具为hostapd。
wpa_supplicant运行于后台,它需要借助控制台工具wpa_cli来进行手动操作。
wpa_supplicant配置文件
Config文件
在wpa_supplicant源码目录下,存在参考的配置文件wpa_supplicant.conf,几乎包含里所有的配置项。
我们的配置文件不需要这么复杂,开始测试阶段,我只写最简单的配置文件,其它手动操作先。
在/etc/下建立配置文件wpa_supplicant.conf,内容如下:
|
ctrl_interface=/var/run/wpa_supplicant update_config=1 |
其中,update_config=1使能配置更改。
wpa_supplicant参数
wpa_supplicant可以通过如下命令查看其所有操作参数:
|
#wpa_supplicant --help wpa_supplicant: invalid option -- - wpa_supplicant v0.8.x Copyright (c) 2003-2011, Jouni Malinen <j@w1.fi> and contributors This program is free software. You can distribute it and/or modify it under the terms of the GNU General Public License version 2. Alternatively, this software may be distributed under the terms of the BSD license. See README and COPYING for more details. 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 (GPL and 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 |
其中最常用的为:-i 指定端口,-c 指定配置文件,-D 指定使用的wifi驱动
我们这里只指定端口和配置文件,驱动使用默认的。
wpa_supplicant启动操作命令如下:
|
#wpa_supplicant -i ath0 -c /etc/wpa_supplicant.conf & |
注意:启动wpa_supplicant之前wifi必须先启动,wpa_supplicnat使用在wifi client端口上。
在测试过程中,如果出现问题,可以在wpa_supplicant启动时使用参数使其输出更多的debug信息:
#wpa_supplicant -i ath0 -c /etc/wpa_supplicant.conf -dddd
手动操作
wpa_supplicant启动后,就可以通过wpa_cli来操作设置了。
wpa_cli操作有两种方法,一是直接进入CLI控制台操作,如下:
#wpa_cli
|
# wpa_cli wpa_cli v0.8.x Copyright (c) 2004-2011, Jouni Malinen <j@w1.fi> and contributors This program is free software. You can distribute it and/or modify it under the terms of the GNU General Public License version 2. Alternatively, this software may be distributed under the terms of the BSD license. See README and COPYING for more details. Selected interface 'ath0' Interactive mode > add 0 > list_network network id / ssid / bssid / flags 0 any [DISABLED] > |
另一种是直接在终端中敲击完整的命令行操作,如下:
|
# wpa_cli -i ath0 set_network 0 ssid '"206"' OK |
这两种方法的效果是一样的,主要区别如下:
wpa_cli控制台中写的命令行要简单些,不需要指定端口(如wpa_cli –i ath0),但写错了不能回退,需要重新完整写入
终端写入的命令行长写,但写错里可以回退重新写。
对于ssid和密码,终端中操作时需要使用单引号把双引号的字符包括起来,而cli控制台中只需要双引号,如下:
|
> set_network 0 psk "12345678" OK |
wpa_cli支持的所有命令可以通过help操作来查看
|
> help |
扫描于连接
以下是我的一个完整的扫描连接过程:
启动wpa_supplicant和wpa_cli.
|
# wpa_supplicant -i ath0 -c /etc/wpa_supplicant.conf & # wpa_cli |
扫描ap
使用scan命令扫描网络,结束后使用scan_results命令查看网络。
|
> scan OK > driver_atheros_event_wireless: scan result event - SIOCGIWSCAN <3>CTRL-EVENT-SCAN-RESULTS <3>WPS-AP-AVAILABLE > > scan_results bssid / frequency / signal level / flags / ssid 00:23:68:26:40:c8 2412 36 [ESS] CMCC 00:26:5a:26:33:ac 2437 38 [WPA-PSK-TKIP][WPA2-PSK-TKIP][WPS][ESS] LZ205 > |
增加网络
使用add_network命令增加一个网络,可以使用list_network查看增加的网络信息。
|
> add_network 0 > list_network network id / ssid / bssid / flags 0 any [DISABLED] |
设定网络连接的ssid和密码
使用set_network命令设定连接的ap的用户名和密码
|
> set_network 0 ssid "LZ205" OK > set_network 0 psk "20100208" OK |
使能网络连接
使用enable_network命令使能网络连接
|
> enable_network 0 OK > driver_atheros_event_wireless: scan result event - SIOCGIWSCAN ath0: Trying to associate with 00:26:5a:26:33:ac (SSID='LZ205' freq=2437 MHz) <3>CTRL-EVENT-SCA ieee80211_ioctl_setmlme: os_opmode=1 [ieee80211_ioctl_setmlme] set desired bssid 00:26:5a:26:33:ac N-RESULTS <3>WPS-AP-AVAILABLE <3>Trying to associate with 00:26:5a:26:33:ac (SSID='LZ205' freq=2437 MHz) ath_paprd_cal PAPRD excessive failure disabling PAPRD now ath0: Associated with 00:26:5a:26:33:ac <3>Associated with 00:26:5a:26:33:ac vap-0: mlme_sta_swbmiss_timer_handler: SW Beacon miss!! vap-0: mlme_sta_swbmiss_timer_handler: SW Beacon miss!! vap-0: ieee80211_vap_iter_beacon_miss: Beacon miss, will indicate to OS!! ath0: WPA: 4-Way Handshake failed - pre-shared key may be incorrect <3>WPA: 4-Way Handshake failed - pre-shared key may be incorrect ath0: CTRL-EVENT-DISCONNECTED bssid=00:26:5a:26:33:ac reason=0 <3>CTRL-EVENT-DISCONNECTED bssid=00:26:5a:26:33:ac reason=0 ieee80211_ioctl_setmlme: os_opmode=1 sult event - SIOCGIWSCAN [ieee80211_ioctl_setmlme] set desired bssid 00:26:5a:26:33:ac <3>CTRL-EVENT-SCAN-RESULTS <3>WPS-AP-AVAILABLE ath0: Trying to associate with 00:26:5a:26:33:ac (SSID='LZ205' freq=2437 MHz) <3>Trying to associate with 00:26:5a:26:33:ac (SSID='LZ205' freq=2437 MHz) ath0: Associated with 00:26:5a:26:33:ac <3>Associated with 00:26:5a:26:33:ac ath0: WPA: Key negotiation completed with 00:26:5a:26:33:ac [PTK=TKIP GTK=TKIP] <3>WPA: Key negotiation completed with 00:26:5a:26:33:ac [PTK=TKIP GTK=TKIP] ath0: CTRL-EVENT-CONNECTED - Connection to 00:26:5a:26:33:ac completed (auth) [id=0 id_str=] <3>CTRL-EVENT-CONNECTED - Connection to 00:26:5a:26:33:ac completed (auth) [id=0 id_str=] |
看到CTRL-EVENT-CONNECTED信息,表示连接完成。
状态查看
使用status命令可以查看网络状态,使用quit退出CLI后,可以使用iwconfig命令查看ath0连接状态。
|
> status bssid=00:26:5a:26:33:ac ssid=LZ205 id=0 mode=station pairwise_cipher=TKIP group_cipher=TKIP key_mgmt=WPA2-PSK wpa_state=COMPLETED address=20:13:08:15:16:13 |
config保存
使用save命令可以保存当前的连接设置,下次wifi启动时会自动连接此AP.
保存后,wpa_supplicant.conf文件被自动修改为如下内容:
|
ctrl_interface=/var/run/wpa_supplicant update_config=1 device_type=0-00000000-0 network={ ssid="LZ205" psk="20100208" } |
自动连接
若希望wifi启动后自动连接到预先设置的ap,只需按如下设置脚本即可以,如果预先设置里多个ap则每个网络需要设置优先级参数priority。
|
ctrl_interface=/var/run/wpa_supplicant update_config=1 network={ ssid="LZ205" psk="20100208" priority=2 |
supplicant的更多相关文章
- wifi测试相关(iwconfig,WPA Supplicant用法)
iwconfig用法 1.打开无线网卡电源 iwconfig wlan0 txpower no 2.列出区域内的无线网络 iwconfig wlan0 scan 3.假设要连接到网络myhome(即e ...
- WPA Supplicant 用法
本文译至:https://wiki.archlinux.org/index.php/WPA_Supplicant_%28%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87%29 ...
- Unable to open connection to supplicant on "/data/misc/wifi/sockets/wlan0"
在调试android wifi UI 的时候,出现了 logcat: Unable to open connection to supplicant on "/data/misc/wifi ...
- (wifi)wifi移植之命令行调试driver和supplicant
前言 小弟从事android wifi framework部分开发已经有一年的时间了,虽然感觉什么都没有学习到,但是回想起刚接手android wifi时候的那份无知,其实肚子里面还是有点东西的,本着 ...
- wpa supplicant 保存 wifi 设置
wpa suppliclant使用wpa gui连接wifi后,下次开机的时,不能保存,需要从新手动进行连接. 自动保存方法: 配置文件/etc/wpa_supplicant.conf 添加 upda ...
- wpa supplicant 移植
最近移植wifi,WIFI芯片使用rtl8723.在文件系统生成了设备节点.需要移植工具进行测试: iwconfig:没有密码的或者wep加密的wifi,使用iwconfig就已经够用. wpa_su ...
- Ubuntu15.10下华南师大锐捷认证客户端的使用详解
本文测试Linux系统环境为Ubuntu15.10 Destop,暂未在其他系统下验证过,不代表LTS版本或较旧的版本按照本文所述方法可以100%正确使用最新的锐捷认证客户端. 本文面向对象为华南师范 ...
- linux commands
abrt-cli --since ;查看abrt捕捉的异常 alias ;别名,alias rm='rm -i':使用“ \rm ” 使用原命令 alsamixer ;图形音量调节,q 增加左声道, ...
- Linux From Scratch(从零开始构建Linux系统,简称LFS)- Version 7.7(三)
八. 构建LFS系统 1. 准备虚拟内核文件系统 内核会挂载几个文件系统用于自己和用户空间程序交换信息.这些文件系统是虚拟的,并不占用实际磁盘空间, 它们的内容会放在内存里. mkdir -pv $L ...
随机推荐
- 学习记录 彻底搞清 C#中a++与++a的区别
首先 a++和++a 的定义:看个例子A: a=5; b=++a; // 相当于a=a+1;b=a; 结果是a=6,b=6B: a=5; b=a++; // 相当于b=a;a=a+1; 结果是a=6, ...
- ubuntu多网卡绑定
这是最近碰到这个问题,需要将两张网卡绑定,共用一个IP,实现冗余效果.实际上linux双网卡的绑定模式有7中,而在这里常用的是 active-backup linux有七种网卡绑定模式:0. roun ...
- meta 标签属性(网站兼容与优化需要)
概要 标签提供关于HTML文档的元数据.元数据不会显示在页面上,但是对于机器是可读的.它可用于浏览器(如何显示内容或重新加载页面),搜索引擎(关键词),或其他 web 服务. —— W3School ...
- Linux:系统的密码忘记了,登录不上
可先通过进入单用户模式,修改下密码再登录记录. 第一步: 重启系统,在进入系统之前不断的按键盘左上角的“Esc”键,会进入如下页面: 然后按e进入编辑页面 第二步: 进入如下页面后,通过键盘的上下方向 ...
- Atom markdown .md 编写格式技巧
使用Atom预览markdown 1.打开任意.md文件(markdown源文件) 菜单栏File->Open file...(ctrl+o)打开文件: 2.windows下使用快捷键 ctrl ...
- nice和taskset命令
taskset -c 9,10 bash domain_analysis.sh && /home/work/odp/php/bin/php hourly_localdns_hijack ...
- 添加 SecondaryNameNode
网络上的很多人写的过程都是错的,关键配置反而不写. SecondaryNameNode的启动有两种方式 一:在整个hdfs系统启动时,在namenode上执行start-dfs.sh则namenode ...
- Android开发教程app下载无法成功创建问题
本文明来给各位同学介绍一下关于cordova cteate app 时下载失败无法成功创建的解决方法,有碰到此问题的同学可进入参考. 使用如下语句创建一个cordova应用: 代码如下 cordova ...
- 实现Win7远程桌面关机和重启
通过远程桌面控制Win7系统时,菜单中没有关机和重启按钮, 1.方法1 关机 shutdown -s -t 0重启 shutdown -r -t 0 可以先打开运行框(Win+R键),输入上述命令即可 ...
- linux启动后自动登录并运行自定义图形界面程序
在<Ubuntu CTRL+ALT+F1~F6 进入命令模式后不支持中文显示的解决办法>一文中提到linux启动在以后运行一个独占显示器的图形程序的两种办法. 1.不启动xserver,使 ...