wpa_cli 连接 wifi

转自:http://hi.baidu.com/yyangjjun/item/9dfe8e175439fc7a1009b5ba

1: run wpa_supplicant first

use the following command:
wpa_supplicant -Dwext -iwlan0 -C/data/system/wpa_supplicant -c/data/misc/wifi/wpa_supplicant.conf

2: Run the command line tool wpa_cli to connect wifi

wpa_cli -p/data/system/wpa_supplicant -iwlan0
Then , it will let you set network interactively

some common command:
>scan = to scan the neighboring AP
>scan_results = show the scan results
>status = check out the current connection information
>terminate = terminate wpa_supplicant
>quit = exit wpa_cli
>add_network = it will return a network id to you
>set_network <network id> <variable> <value> = set network variables (shows list of variables when run without arguments), success will return OK, or will return Fail
>select_network <network id> = select a network (disable others)
>disable_network <network id> = disable a network
>enable_network <network id> = enable a network
> set_network 0 priority 0
> list_network
> save_config

3: example
for AP that doesn`t have encryption
>add_network      (It will display a network id for you, assume it returns 0)
>set_network 0 ssid “666”
>set_network 0 key_mgmt NONE
>enable_network 0
>quit

if normal, we have connectted to the AP “666”, now you need a IP to access internet, for example:
dhcpcd wlan0
if everything is ok, it will get an IP & can access internet

for AP that has WEP
>add_network      (assume returns 1)
>set_network 1 ssid “666”
>set_network 1 key_mgmt NONE
>set_network 1 wep_key0 “your ap passwork”(if usting ASCII, it need double quotation marks, if using hex, then don`t need the double quotation marks)
>set_network 1 wep_tx_keyidx 0
>select_network 1  (optional, remember, if you are connecting with another AP, you should select it to disable the another)
>enable_network 1
and then ,get an IP to access internet

for AP that has WPA-PSK/WPA2-PSK
>add_network      (assume returns 2)
>set_network 2 ssid “666”
>set_network 2 psk “your pre-shared key”
>select_network 2  (optional, remember, if you are connecting with another AP, you should select it to disable the another)
>enable_network 2

there is still some others options to be set, but wpa_supplicant will choose the default for you, the default will include all we need to set and then ,get an IP to access internet

命令执行后,wpa_cli 会输出连接的过程信息。如果一切正确,则最后后输出:
<2>CTRL-EVENT-CONNECTED - Connection to xx:xx:xx:xx:xx:xx completed (reauth) [id=0 id_str=]

获取IP地址
用 quit
命令退出wpa_cli 。然后用
dhclient wlan0
命令获取IP地址。

时间: 2024-10-21 10:37:22

wpa_cli 连接 wifi的相关文章

Android代码连接Wifi时被系统切换到其他Wifi的问题

首先说下Android代码连接Wifi的几个步骤:(以下涉及到具体API函数自查哈,写的时候凭借印象大致写了下) 转载请注明出处: 胖虎:http://blog.csdn.net/ljphhj 1.首先要开启Wifi连接开关,mWifiManager.setWifiEnabled(true) 2.通过获取List<ScanResult>来获取到Wifi连接列表.(mWifiManager.getScanResults) 3.获取List<WifiConfiguration>列表.(

linux无法连接wifi,不显示wifi

首先感谢Ubuntu 无线网络连接WIFI(b43驱动出现DMA问题的解决,根据文章的命令找到了问题所在. 1. dmesg | grep b43 (找到问题) dmesg用于检测和控制内核缓冲,帮助用户了解系统的启动信息. 系统提示到Linux Wireless我们到这里下载firmware,我们直接点击Linux Wireless,打开之后我们发现它提醒说The old website for now has a copy of the old content:Old Linux Wirel

树莓派 连接wifi与路由器ip绑定

先推荐几个手机软件 在酷安网里应该能找到 1.JuiceSSH  橘子ssh软件  手机连上路由器 就可以控制局域网内的树莓派 2.VNC Viewer  远程桌面软件VNC 也是连接局域网的树莓派 这几个软件还是很好用的,不想开电脑的时候,也能控制树莓派 ---------------------------------------------------------------------------------------------------------- 正文:连接wifi和路由器i

ubuntu 命令行模式连接wifi

ubuntu因为某些原因不能进入图形界面,而又没有网口时,需要连接wifi更新网络.而wifi变更了很多.wep模式已经淘汰,大量wpa模式的wifi,这里描述整个流程,以及可能遇到的坑. 列举你所有的网卡设备.找到你的无线网卡,这里是wlan2 ifconfig 打开wlan接口 ifconfig wlan2 up/ifup wlan2 查找所有可用的wifi接入点,记录接入点名称(essid).这里是tp_liNK iwlist scanning 因为wpa模式的密码,你输入的和实际使用的有

连接Wifi

  public interface ScanWiFIScanListener { void scanList(List<INfo> list); } public class INfo { String ssid;// String capabilities;// String bssid;// int level;//信号强度-20到0是最强的 public String getSsid() { return ssid; } public void setSsid(String ssid)

为什么手机连接wifi会显示已停用?

1.通常导致手机连接WiFi显示“已停用”故障的原因是由于无线路由器“安全模式”设置不当造成的,对此我们可以通过以下方法来解决: 2.根据无线路由器背面的信息(包括路由器IP地址,登陆用户名和密码),登陆路由器管理地址: 3.在路由器管理界面中,切换到“无线设置”选项卡,点击“无线加密”项,在此界面可以设置“安全模式”: 4.点击“安全模式”下拉列表,从其扩展列表中选择“WPA2-PSK”项,此项是所有手机均可支持的安全加密模式: 5.点击“确定”按钮保存设置.最后切换到“系统工具”选项卡,点击

yoga安装kali备忘(连接wifi)

kali 2.0 iso win8 下安装 用 WinSetupFromUSB-1-6-beta2 写入u盘,正常安装系统 启动连接wifi 搜索信号,获取ssid iw wlan0 scan 查看是否连接 iw wlan0 link 写入需要连接的无线路由信息 wpa_passphrase SSID PASSWD |tee -a /etc/wpa_supplicant/wpa_supplicant.conf 连接路由 wpa_supplicant -B -D wext -i wlan0 -c

Linux 使用create_ap开热点后无法连接wifi问题的解决

使用create_ap开启热点,关闭后,无法连接wifi. 使用sudo rfkill list all发现wifi没有被锁住,使用 sudo service network-manager start也无法解决问题 后来使用create_ap -h查看此软件的相关帮助,其中有 --fix-unmanaged If NetworkManager shows your interface as unmanaged after you close create_ap, then use this o

android推断是否连接wifi和网络状态的推断

<span style="font-size:18px;">// 是否连接WIFI public static boolean isWifiConnected(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiNet