首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

转载:Linux上使用wpa_supplicant连接WPA加密方式的WIFI

2012-07-05 
转载:Linux下使用wpa_supplicant连接WPA加密方式的WIFIFull commandShort commandDescriptionstatusstatdi

转载:Linux下使用wpa_supplicant连接WPA加密方式的WIFI

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>

相应的参数如下表:

/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"

}

具体格式可参考:http://hostap.epitest.fi/gitweb/gitweb.cgi?p=hostap.git;a=blob_plain;f=wpa_supplicant/wpa_supplicant.conf

热点排行