wpa_supplicant无线网络配置
目前可以使用wireless-tools 或wpa_supplicant工具来配置无线网络。请记住重要的一点是,对无线网络的配置是全局性的,而非针对具体的接口。
wpa_supplicant是一个较好的选择,但缺点是它不支持所有的驱动。请浏览wpa_supplicant网站获得它所支持的驱动列表。另外,wpa_supplicant目前只能连接到那些你已经配置好ESSID的无线网络。wireless-tools支持几乎所有的无线网卡和驱动,但它不能连接到那些只支持WPA的AP。
经过编译后的wpa_supplicant源程序可以看到两个主要的可执行工具:wpa_supplicant和wpa_cli。wpa_supplicant是核心程序,它和wpa_cli的关系就是服务和客户端的关系:后台运行wpa_supplicant,使用wpa_cli来搜索、设置、和连接网络。
如何用wpa_supplicant使能一个wifi连接?
Step by step:
1、运行wpa_supplicant程序;
执行:/system/bin/wpa_supplicant -d -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
其中:
-d :增加调试信息
-Dwext :wext,驱动名称
-iwlan0 :wlan0,网络接口名称
/system/bin/wpa_supplicant :wpa_supplicant可执行程序path
/data/misc/wifi/wpa_supplicant.conf :wpa_supplicant的配置文件path
2、运行命令行工具wpa_cli ;
执行 :wpa_cli -iwlan0 -p/data/system/wpa_supplicant
注,-p/data/system/wpa_supplicant中的wpa_supplicant并不是可执行程序,而是个控制套接字。
此时会进入交互模式。其中交互模式的命令如下表:
Full command |
Short command |
Description |
status |
stat |
displays the current connection status |
disconnect |
disc |
prevents wpa_supplicant from connecting to any access point |
quit |
q |
exits wpa_cli |
terminate |
term |
kills wpa_supplicant |
reconfigure |
recon |
reloads wpa_supplicant with the configuration file supplied (-c parameter) |
scan |
scan |
scans for available access points (only scans it, doesn't display anything) |
scan_result |
scan_r |
displays the results of the last scan |
list_networks |
list_n |
displays a list of configured networks and their status (active or not, enabled or disabled) |
select_network |
select_n |
select a network among those defined to initiate a connection (ie select_network 0) |
enable_network |
enable_n |
makes a configured network available for selection (ie enable_network 0) |
disable_network |
disable_n |
makes a configured network unavailable for selection (ie disable_network 0) |
remove_network |
remove_n |
removes a network and its configuration from the list (ie remove_network 0) |
add_network |
add_n |
adds a new network to the list. Its id will be created automatically |
set_network |
set_n |
shows a very short list of available options to configure a network when supplied with no parameters. See next section for a list of extremely useful parameters to be used with set_network and get_network. |
get_network |
get_n |
displays the required parameter for the specified network. See next section for a list of parameters |
save_config |
save_c |
saves the configuration |
设置网络的基本格式:set_network <network id> <key> <parameter> [<parameter>]
显示网络信息的基本格式:get_network <network id> <key>
相应的参数如下表:
Key |
Description |
Parameters |
ssid |
Access point name |
string |
id_str |
String identifying the network |
string |
priority |
Connection priority over other APs |
number (0 being the default low priority) |
bssid |
Mac address of the access point |
mac address |
scan_ssid |
Enable/disbale ssid scan |
0, 1, 2 |
key_mgmt |
Type of key management |
WPA-PSK, WPA_EAP, None |
pairwise |
Pairwise ciphers for WPA |
CCMP, TKIP |
group=TKIP |
Group ciphers for WPA |
CCMP, TKIP, WEP104, WEP40 |
psk |
Pre-Shared Key (clear or encrypted) |
string |
wep_key0 |
WEP key (up to 4: wep_key[0123]) |
string |
eap |
Extensible Authentication Protocol |
MD5, MSCHAPV2, OTP, GTC, TLS, PEAP, TTLS |
identity |
EAP identity string |
string |
password |
EAP password |
string |
ca_cert |
Pathname to CA certificate file |
/full/path/to/certificate |
client_cert |
Pathname to client certificate |
/full/path/to/certificate (PEM/DER) |
private_key |
Pathname to a client private key file |
/full/path/to/private_key (PEM/DER/PFX) |
eg.1、连接无加密的AP
>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
eg.2、连接WEP加密AP
>add_network (assume return 1)
>set_network 1 ssid "666"
>set_network 1 key_mgmt NONE
>set_network 1 wep_key0 "your ap password"
>enable_network 1
eg.3、连接WPA-PSK/WPA2-PSK加密的AP
>add_network (assume return 2)
>set_network 2 ssid "666"
>set_network 2 psk "your pre-shared key"
>enable_network 2
到此,wifi模块就能连接上AP了。
3、以上是通过命令行工具wpa_cli来实现wifi网络的连接。当然,也可以通过wpa_supplicant的配置文件来实现连接。
再回顾下运行wpa_supplicant时执行的命令:
/system/bin/wpa_supplicant -d -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
我们在执行时加上了-c/data/misc/wifi/wpa_supplicant.conf,我们可以将我们要连接的AP的设置以一定的格式写入wpa_supplicant.conf配置文件中即可。
eg.
ctrl_interface=DIR=/data/system/wpa_supplicant GROUP=system update_config=1
network={
ssid="my access point"
proto=WPA
key_mgmt=WPA-PSK
psk="you pass words"
}
wpa_supplicant无线网络配置的更多相关文章
- Linux下面无线网络配置
原文:http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html 配置 WLAN 特定参数 iwconfig ethX essid ...
- linux无线网络配置_转
转自:http://www.cnblogs.com/dartagnan/archive/2010/12/05/2003521.html 一位资生linux 原文:http://www.hpl.hp ...
- linux 无线网络配置工具wpa_supplicant与wireless-tools
4.a. 介绍目前您可以使用我们提供的wireless-tools 或wpa_supplicant工具来配置无线网络.请记住重要的一点是,您对无线网络的配置是全局性的,而非针对具体的接口.wpa_su ...
- Gentoo 无线网络配置 wpa_supplicant
安装 安装net-wireless/wpa_supplicant包 emerge --ask wpa_supplicant 启动网络 为wpa_supplicant添加无线接口 在wpa_suppli ...
- blfs(systemd版本)学习笔记-安装、配置和使用wpa_supplicant无线网络连接工具
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! wireless项目地址:http://www.linuxfromscratch.org/blfs/view/stable-sy ...
- blfs(systemv版本)学习笔记-安装、配置和使用wpa_supplicant无线网络连接工具
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! wireless项目地址:http://www.linuxfromscratch.org/blfs/view/8.3/basic ...
- CentOS 7 最小化安装的无线网络配置
1.首先下载iw工具. yum -y install iw 2.获取无线网卡的名称 执行iw dev,假设获得名称为 wlp3s0(示例) 3.激活无线网络接口 执行ip link set wlp3s ...
- Linux之Ubuntu无线网络配置
无线网络使用问题: 0.插上有线网络电线与电脑NIC上. 1.set->系统设置->软件和更新->Ubuntu软件->下载自: 选择一个网络服务器地址(软件源)[http: ...
- centOS6.2 最小安装下的无线网络配置
一.安装wireless_tools,http://www.linuxfromscratch.org/blfs/view/svn/basicnet/wireless_tools.html 二.vi / ...
随机推荐
- JSON 学习总结 <一>:什么是JSON
JSON的相关资料和博客很多,JSON无处不用,最近项目中一直要用到JSON,今天没有加班,就写下,算是对自己的总结,对JSON又一次深入的认识. 废话不多了,直接进入今天的主题: 如题:今天就介绍下 ...
- (转)Spring 读书笔记-----使用Spring容器(一)
Spring有两个核心接口:BeanFactory和ApplicationContext,其中ApplicationContext是BeanFactory的子接口.他们都可代表Spring容器,Spr ...
- Activity是如何挂载Pargment的Day35
Activity是如何挂载Pargment的Day35 mebile5.0 1.Fragment优化早上任务 思路 一个主Activity 短信群发器 中秋给朋友发短信,都能够加上他们的姓名,这样他们 ...
- 设计webapp的新思路
一般设计移动应用有3中方式:原生.脚本.混合:今天我们用另一种方式实现. 我叫它:响应式网页webApp 一.具体构架思路是这样的: 客户端:Android手机 Android手机中有控件WebVie ...
- oracle的学习 第二节:创建数据表
学习内容: A.创建数据库和表空间 B.创建用户和分配权限 C.创建数据表 一.创建数据库和表空间 (一)SQL语言的基本概念 1.概念 高级的结构化查询语言:沟通数据库服务器和客户的重要桥梁. PL ...
- CI 自动操作日志
在控制器中,继承一个总控制器,MY_Controller,让其他集成的控制器,继承my控制器 在MY_Controller控制器中,重写构造方法, 代码如下,测试pass! class MY_Cont ...
- object-C 手动内存管理(MRC)
object-C的内存管理和javascript的垃圾回收不一样,今天总结下手动内存管理,ARC的后边补上. 1:基本铺垫 oc采用引用计数来表示对象的状态,比如通过init创建出来的一个对象引用计数 ...
- Java中报错No enclosing instance of type caiquan is accessible. Must qualify the allocation with an enclosing instance of type caiquan (e.g. x.new A() where x is an instance of caiquan).
package test;import java.util.Scanner;import java.util.Random;public class caiquan { public static v ...
- winForm帮助信息
在项目开发中,由于没更新一块内容,帮助文档都得及时更新,否则将导致最新的应用程序与帮助文档不一致.为此,写了一个帮助页面,这样就可以实时看到帮助信息. 首先,新建了一个帮助信息类,代码如下: /// ...
- 精通 Oracle+Python,第 6 部分:Python 支持 XML
无可辩驳的是,XML 现在是软件中信息交换的实际标准. 因此,Oracle 数据库附带了各种与 XML 相关的增强和工具,它们统称为 Oracle XML DB.XML DB 包含一系列嵌入到数据库中 ...