1. 程式人生 > >wpa_cli 關聯無線網路

wpa_cli 關聯無線網路

fq關聯無線網路,不同的無線網路認證方式不同設定:
    1)open(開放式認證方式,分為):
         wpa_cli -iwlan0 set_network 0 ssid '"wlan"'(PS:wlan是無線的ssid號,外面是一對雙引號,然後再外面是一對單引號)
         wpa_cli -iwlan0 set_network 0 key_mgmt NONE
    2)wep(分為開放式和共享式):
         wpa_cli -iwlan0 set_network 0 ssid '"wlan"'
         wpa_cli -iwlan0 set_network 0 key_mgmt NONE
         wpa_cli -iwlan0 set_network 0 wep_key0 '"wlan_key"'
         如果是共享式,還需要配置:wpa_cli -iwlan0 set_network 0 auth_alg SHARED(預設是開放式,可以不配置)
     3)WPA/WPA2-Personal認證方式:
           wpa_cli -iwlan0 set_network 0 ssid '"wlan"'
         wpa_cli -iwlan0 set_network 0 key_mgmt WPA-PSK
         wpa_cli -iwlan0 set_network 0 proto WPA(WPA2)
         wpa_cli -iwlan0 set_network 0 pairwise TKIP(CCMP)
         wpa_cli -iwlan0 set_network 0 group TKIP(CCMP)
         wpa_cli -iwlan0 set_network 0 psk '"wlan_password"'
       4)WPA/WPA2-Enterprise認證方式:
          wpa_cli -iwlan0 set_network 0 ssid '"wlan"'
          wpa_cli -iwlan0 set_network 0 key_mgmt WPA-EAP
          wpa_cli -iwlan0 set_network 0 pairwise TKIP(CCMP)
          wpa_cli -iwlan0 set_network 0 group TKIP(CCMP)
          wpa_cli -iwlan0 set_network 0 eap PEAP
          wpa_cli -iwlan0 set_network 0 identity '"username"'
          wpa_cli -iwlan0 set_network 0 password '"password"'
          如果是WPA2-Enterprise認證:需要設定proto:wpa_cli -iwlan0 set_network 0 protoWPA2
       然後開始關聯:wpa_cli -iwlan0 enable_network 0
       如果dhcp獲取ip地址,需要等關聯上之後去dhcp;檢視關聯狀態wpa_cli -iwlan0 status
       如果狀態是complete的話:dhcp wlan0
     
  一般操作過程是,先檢視無線網路,是否要關聯的無線網路可見:
      wpa_cli -iwlan0 scan
      wpa_cli -iwlan0 scan_results
  如果可見,則如上配置network 0,然後關聯:
      wpa_cli -iwlan0 enable_network 0
      wpa_cli -iwlan0 status如果關聯上,dhcp wlan0
 
  之後如果解關聯,需要先釋放IP,然後up埠,然後解關聯:
     dhcp -r wlan0
    (需要等待一會,等待release完ip)
    然後ifconfig wlan0 up
    最後wpa_cli -iwlan0 disable_network 0
4. udhcpc -i wlan0                                //
    route add  default gw 192.168.43.1   //修改閘道器
---------------------
作者:shexujia
來源:CSDN
原文:https://blog.csdn.net/shexujia/article/details/18302007
版權宣告:本文為博主原創文章,轉載請附上博文連結!