How to use wpa_cli command
wpa_cli command เป็น command ที่มีอยู่ใน wpa_supplicant package ซึ่ง command นี้จะสามารถตรวจสอบสถานะการทำงาน, การแก้ไขค่า configurationต่างๆไม่ว่าจะเป็น trigger events หรือการใส่ค่าของ passphase เมื่อเวลา connect wireless
การใช้งาน wpa_cli command
ในการทำงานของ wpa_cli นี้จะสามารถทำงานได้ 2 mode การทำงานคือ command line interpreter เช่น wpa_cli -i eth1 scan หรือ interactive shell เช่น wpa_cli -i eth1 ในการใช้งานเราสามารถพิมพ์ command แบบย่อได้อย่างเช่น ต้องการตรวจสอบสถานะก็สามารถพิมพ์ได้ว่า wpa_cli -i eth1 stat แทนการพิมพ์ wpa_cli -i eth1 status ซึ่งรายละเอียดของคำสั่งแบบย่อนี้สามารถดูได้จากตารางด้านล่างนี้
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_display | scan_d | 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 |
การใช้คำสั่ง wpa_cli ด้วย command set_networkสามารถใช้งา่นดังตัวอย่างด้านล่าง
set_network <network id> <key> <parameter> [<parameter>]
การใช้คำสั่ง wpa_cli ด้วย command get_networkสามารถใช้งา่นดังตัวอย่างด้านล่าง
get_network <network id> <key>
ในส่วนของพารามิเตอร์ key ของทั้ง set_network และ get_network สามารถดูรายละเอียดได้ดังตารางด้านล่าง
Key | Description | Parameters |
ssid | Access point name | string |
id_str | String identifying the network | string |
priority | Connection priority over other APs | number (0 being the default low priority) |
bssid | Mac address of the access point | mac address |
scan_ssid | Enable/disbale ssid scan | 0, 1, 2 |
key_mgmt | Type of key management | WPA-PSK, WPA_EAP, None |
pairwise | Pairwise ciphers for WPA | CCMP, TKIP |
group=TKIP | Group ciphers for WPA | CCMP, TKIP, WEP104, WEP40 |
psk | Pre-Shared Key (clear or encrypted) | string |
wep_key0 | WEP key (up to 4: wep_key[0123]) | string |
eap | Extensible Authentication Protocol | MD5, MSCHAPV2, OTP, GTC, TLS, PEAP, TTLS |
identity | EAP identity string | string |
password | EAP password | string |
ca_cert | Pathname to CA certificate file | /full/path/to/certificate |
client_cert | Pathname to client certificate | /full/path/to/certificate (PEM/DER) |
private_key | Pathname to a client private key file | /full/path/to/private_key (PEM/DER/PFX) |
ตัวอย่างการใช้งาน set_network ด้วยวิธี command line:
set_network 0 ssid "my access point" set_network 0 id_str Home_Network set_network 0 bssid 00:0d:0b:64:00:6c set_network 0 scan_ssid 0 set_network 0 key_mgmt WPA-PSK set_network 0 pairwise CCMP TKIP set_network 0 group CCMP TKIP set_network 0 psk "makemeveryverysecret" set_network 0 EAP TLS set_network 0 "[email protected]" set_network 0 ca_cert "/etc/cert/ca.pem" set_network 0 client_cert "/etc/cert/user.pem" set_network 0 private_key "/etc/cert/user.prv"
ตัวอย่างการ setting set_network keys ในไฟล์ wpa_supplicant.conf:
network={ ssid="my access point" id_str="Home_Network" bssid=00:0d:0b:64:00:6c scan_ssid=0 key_mgmt=WPA-PSK pairwise=CCMP TKIP group=CCMP TKIP psk=c2277f7dd8cb0000fe000000b76cfda7102ed7eefbd29ad0000000000f5e349a }
ขอขอบคุณข้อมูลจากทาง Red Hat ครับ