Linux系統Wpa_supplicant用法小結

double2li發表於2015-10-10

Wpa_supplicant是linux系統下一個非常強大的無線網路卡管理程式。google搜尋到的它似乎不支援WPA2和AES,其實不然,參考它的文件可以發現,WPA2只是RSN的別名,而AES也是CCMP的一部分,所以它們的支援完全是沒有問題的。

它的文件看起來非常複雜,其實配置非常簡單,下面先給出我的wpa_supplication.conf

 

[python] view plaincopy
 
  1. ctrl_interface=/var/run/wpa_supplicant  
  2. ctrl_interface_group=wheel  
  3. update_config=1  
  4.   
  5. network={  
  6.     ssid=“xxxx”  
  7.     scan_ssid=1  
  8.     psk=xxxxxxxxx37bca5cf24a345f514d319211822f568bba28f8f0b74c894e7644  
  9.     proto=RSN  
  10.     key_mgmt=WPA-PSK  
  11.     pairwise=CCMP  
  12.     auth_alg=OPEN  
  13. }  

解釋一下上面的比較容易困惑的地方:

 

簽名三句應該是個模板,沒仔細研究過。

network=開始是無線接入點的具體配置,一般的無線接入點可以用wpa_passphrase來自動生成,語法是

 

[python] view plaincopy
 
  1. yj@YJ_N ~ $ wpa_passphrase  
  2. usage: wpa_passphrase <ssid> [passphrase]  
  3.   
  4. If passphrase is left out, it will be read from stdin  
  5.   
  6. 接下來看個例項:  
  7.   
  8. yj@YJ_N ~ $ wpa_passphrase TPLINK 12345678  
  9. network={  
  10.         ssid=“TPLINK”  
  11.         #psk=”12345678″  
  12.         psk=992194d7a6158009bfa25773108291642f28a0c32a31ab2556a15dee97ef0dbb  
  13. }  
  14. 這裡表示名為TPLINK的接入點,密碼是12345678,輸出就是該接入點在wpa_supplicant.conf裡面的配置內容,可以直接用下面的命令自動寫入  
  15.   
  16. yj@YJ_N ~ $ wpa_passphrase TPLINK 12345678 |sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf  

 

繼續解釋最開始的例子,network=後面的內容

ssid :接入點名稱,這個沒什麼好說的

scan_ssid=1 :這個很容易錯過,如果你的無線接入點是隱藏的,那麼這個就是必須的,親身經歷,折騰了好久才搞定,記之備忘。

psk=xx :是加密後的密碼,用wpa_passphrase自動生成的

proto=RSN  WPA2就選這個,抄一下官方配置檔案例子裡面的:

 

[python] view plaincopy
 
  1. # proto: list of accepted protocols —支援的協議列表  
  2. # WPA = WPA/IEEE 802.11i/D3.0    
  3. # RSN = WPA2/IEEE 802.11i (also WPA2 can be used as an alias for RSN) —也能使用WPA2,它只是RSN的一個別名而已  
  4. # If not set, this defaults to: WPA RSN   —如果不設定,預設就是WPA RSN,即全部支援  

 

key_mgmt= 認證金鑰管理協議,還是抄:

 

[python] view plaincopy
 
  1. # key_mgmt: list of accepted authenticated key management protocols  —支援的協議列表  
  2. # WPA-PSK = WPA pre-shared key (this requires `psk` field)     —一般都是這個,這就包括了WPA、WPA2開始的那些方式  
  3. # WPA-EAP = WPA using EAP authentication    —這個就是WEP開頭的,猜的,求驗證  
  4. # IEEE8021X = IEEE 802.1X using EAP authentication and (optionally) dynamically  
  5. #   generated WEP keys  
  6. # NONE = WPA is not used; plaintext or static WEP could be used  —這個是開放的,沒密碼,聯通、電信之類的就這個  
  7. # WPA-PSK-SHA256 = Like WPA-PSK but using stronger SHA256-based algorithms  
  8. # WPA-EAP-SHA256 = Like WPA-EAP but using stronger SHA256-based algorithms  
  9. # If not set, this defaults to: WPA-PSK WPA-EAP —如果未設定,預設支援WAP、WEP開頭那些  

 

pairwise= 這個就是加密方式,繼續抄

 

[python] view plaincopy
 
  1. # pairwise: list of accepted pairwise (unicast) ciphers for WPA   —WPA可用的加密方式列表  
  2. # CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0]  —看到沒,這個就是AES,換了馬甲而已  
  3. # TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0] —TKIP 這個倒是沒變  
  4. # NONE = Use only Group Keys (deprecated, should not be included if APs support  
  5. #   pairwise keys)   —這個估計很少用  
  6. # If not set, this defaults to: CCMP TKIP  —不設定的話是CCMP TKIP,看似正確,其實有些路由器無法自動識別,只能二選一,很坑爹。  

 

好了,其他的不多說了,有興趣看英文原文吧:

wpa_supplicant官方配置檔案(英文)


相關文章