使用wpa supplicant连接无线:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
(未显示同一用户的2个中间版本) | |||
第1行: | 第1行: | ||
= 使用 wpa_supplicant的客户端工具wpa_cli连接无线 = | == 使用 wpa_supplicant的客户端工具wpa_cli连接无线 == | ||
{{DEFAULTSORT:Shinyong}} | |||
[[分类:Orangepi]] | |||
[[分类:Linux]] | |||
wpa_supplicant包含两个主要的可执行工具:wpa_supplicant和wpa_cli。wpa_supplicant是核心程序,它和wpa_cli的关系就是服务和客户端的关系:后台运行wpa_supplicant,使用wpa_cli来搜索、设置、和连接网络。 | wpa_supplicant包含两个主要的可执行工具:wpa_supplicant和wpa_cli。wpa_supplicant是核心程序,它和wpa_cli的关系就是服务和客户端的关系:后台运行wpa_supplicant,使用wpa_cli来搜索、设置、和连接网络。 | ||
apt-get install wireless-tools | |||
在wpa_cli交互模式下可以执行很多命令 ,使用命令 | 在wpa_cli交互模式下可以执行很多命令 ,使用命令 | ||
第10行: | 第15行: | ||
查看相关介绍 | 查看相关介绍 | ||
== 步骤 == | |||
wpa_supplicant -i<wlan0> -D<driver> -B -c</etc/wpa_supplicant/wpa_supplicant.conf | === 1.运行服务端wpa_supplicant === | ||
wpa_supplicant -i<wlan0> -D<driver> -B -c </etc/wpa_supplicant/wpa_supplicant.conf> | |||
<nowiki>*</nowiki>部分linux发行版默认wpa_supplicant服务已运行,使用top命令查询,已运行则不需要再执行此命令,-D参数部分情况下不需要 | <nowiki>*</nowiki>部分linux发行版默认wpa_supplicant服务已运行,使用top命令查询,已运行则不需要再执行此命令,-D参数部分情况下不需要 | ||
=== 2.运行客户端wpa_cli === | |||
wpa_cli -i<ifname> -p<path to ctrl sockets> | |||
<nowiki>*</nowiki>不使用-i参数则使用默认网卡,-p | |||
=== 3.扫描网络信息 === | |||
scan | |||
scan_result | |||
=== 4.添加启用网络 === | |||
add_network | |||
<nowiki>*</nowiki>注意回显编号 | |||
set_network 0 ssid "ssid" | |||
set_network 0 psk "psk" | |||
select_network 0 | |||
enable_network 0 | |||
<nowiki>*</nowiki>0为network编号 | |||
list_network | |||
status | |||
=== 5.保存配置 === | |||
save_config | |||
quit | |||
=== 6.获取IP === | |||
dhclient <ifname> | |||
<nowiki>*</nowiki>获取ip地址 | |||
=== 啥玩意? === | |||
==== 1 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 | |||
==== 2 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 | |||
==== 3 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 | |||
wpa_supplicant -iwlan1 -C /var/run/wpa_supplicant/ -c /etc/wpa_supplicant/wpa_supplicant.conf -B -u -s -O /run/wpa_supplicant | |||
wpa_supplicant -iwlan1 -C /var/run/wpa_supplicant/ -c /etc/wpa_supplicant/wpa_supplicant.conf -B | |||
=== 配置中的坑 === | |||
<blockquote>cat /etc/wpa_supplicant/wpa_supplicant.conf </blockquote> | |||
ctrl_interface=/var/run/wpa_supplicant/ | |||
update_config=1 | |||
PS:<nowiki>http://blog.csdn.net/zhandoushi1982/article/details/24097775</nowiki> |
2018年12月14日 (五) 22:14的最新版本
使用 wpa_supplicant的客户端工具wpa_cli连接无线
wpa_supplicant包含两个主要的可执行工具:wpa_supplicant和wpa_cli。wpa_supplicant是核心程序,它和wpa_cli的关系就是服务和客户端的关系:后台运行wpa_supplicant,使用wpa_cli来搜索、设置、和连接网络。
apt-get install wireless-tools
在wpa_cli交互模式下可以执行很多命令 ,使用命令
wpa_cli -h
man wpa_cli
查看相关介绍
步骤
1.运行服务端wpa_supplicant
wpa_supplicant -i<wlan0> -D<driver> -B -c </etc/wpa_supplicant/wpa_supplicant.conf>
*部分linux发行版默认wpa_supplicant服务已运行,使用top命令查询,已运行则不需要再执行此命令,-D参数部分情况下不需要
2.运行客户端wpa_cli
wpa_cli -i<ifname> -p<path to ctrl sockets>
*不使用-i参数则使用默认网卡,-p
3.扫描网络信息
scan
scan_result
4.添加启用网络
add_network
*注意回显编号
set_network 0 ssid "ssid"
set_network 0 psk "psk"
select_network 0
enable_network 0
*0为network编号
list_network
status
5.保存配置
save_config
quit
6.获取IP
dhclient <ifname>
*获取ip地址
啥玩意?
1 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
2 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
3 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
wpa_supplicant -iwlan1 -C /var/run/wpa_supplicant/ -c /etc/wpa_supplicant/wpa_supplicant.conf -B -u -s -O /run/wpa_supplicant
wpa_supplicant -iwlan1 -C /var/run/wpa_supplicant/ -c /etc/wpa_supplicant/wpa_supplicant.conf -B
配置中的坑
cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant/
update_config=1
PS:http://blog.csdn.net/zhandoushi1982/article/details/24097775