创客百科

姿势共享,有节操无门槛参与的创客百科,创客动力之源 \ (^_^) /

用户工具

站点工具


note:bearchild:wpa_supplican_introduction

这是本文档旧的修订版!


Wpa_supplicant - 树莓派wifi管理器

wpa_supplicant本是开源项目源码,被谷歌修改后加入Android移动平台,它主要是用来支持WEP,WPA/WPA2和WAPI无线协议和加密认证的,它隐藏了WIFI认证的具体细节,使Linux上的WIFI更加“亲民”.

使用方法

如果你是第一次使用,运行:

$ wpa_passphrase <wifi名称> [密码] |sudo tee /etc/wpa.conf
$ sudo reboot

是的,WIFI链接就是如此简单.

配置文件详解

首先,让我们看一看 /etc/wpa_supplicant/wpa_supplicant.conf 的配置

pi@RaspberryPi:~ $ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf  
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

嗯,这些全都是默认的配置,一定不要动它.

树莓派真正的配置文件在/etc/wpa.conf

sudo nano /etc/wpa.conf

什么都没显示,这个文件默认是没有的,就是给用户自定义WIFI用的.

Wpa_supplicant的配置文件像这样

network={  
    ssid="WIFIAP"  
    scan_ssid=1  
    psk=XxXx
    proto=RSN  
    key_mgmt=WPA-PSK  
    pairwise=CCMP  
    auth_alg=OPEN  
}  

运行wpa_passphrase可以创建一个配置文件

pi@RaspberryPi:~ $ wpa_passphrase WIFIAP 12345678 
# 用法:wpa_passphrase <wifi名称> [密码]
network={
        ssid="WIFIAP"
        #psk="12345678"
        psk=bc080289d81bd133a52e4b5525a1a567eae478d907b2e35effaf84bf7ff3859e
}

ssid :接入点名称,这个没什么好说的 scan_ssid=1 :这个很容易错过,如果你的无线接入点是隐藏的,那么这个就是必须设置为一。 psk=xx :是加密后的密码,用wpa_passphrase自动生成

proto=RSN 
支持的协议列表  
WPA = WPA/IEEE 802.11i/D3.0    
RSN = WPA2/IEEE 802.11i (also WPA2 can be used as an alias for RSN) 
      WPA2是RSN的一个别名而已  
      如果不设置,默认就是WPA RSN,即全部支持  
key_mgmt: list of accepted authenticated key management protocols  ---支持的协议列表  
WPA-PSK = WPA pre-shared key (this requires 'psk' field)     ---一般都是这个,这就包括了WPA、WPA2开始的那些方式  
WPA-EAP = WPA using EAP authentication    ---这个就是WEP开头的,猜的,求验证  
IEEE8021X = IEEE 802.1X using EAP authentication and (optionally) dynamically  generated WEP keys  
NONE = WPA is not used; plaintext or static WEP could be used  ---这个是开放的,没密码,联通、电信之类的就这个  
WPA-PSK-SHA256 = Like WPA-PSK but using stronger SHA256-based algorithms  
WPA-EAP-SHA256 = Like WPA-EAP but using stronger SHA256-based algorithms  
If not set, this defaults to: WPA-PSK WPA-EAP ---如果未设置,默认支持WAP、WEP开头那些  
pairwise: list of accepted pairwise (unicast) ciphers for WPA   ---WPA可用的加密方式列表  
CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0]  ---看到没,这个就是AES,换了马甲而已  
TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0] ---TKIP 这个倒是没变  
NONE = Use only Group Keys (deprecated, should not be included if APs support  pairwise keys)   ---这个估计很少用  
If not set, this defaults to: CCMP TKIP  ---不设置的话是CCMP TKIP,看似正确,其实有些路由器无法自动识别,只能二选一,很坑爹。  
本页面的其他翻译:
note/bearchild/wpa_supplican_introduction.1493994627.txt.gz · 最后更改: 2017/05/05 22:30 (外部编辑)