เครือข่ายและ DNS

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 commandShort commandDescription
statusstatdisplays the current connection status
disconnectdiscprevents wpa_supplicant from connecting to any access point
quitqexits wpa_cli
terminatetermkills wpa_supplicant
reconfigurereconreloads wpa_supplicant with the configuration file supplied (-c parameter)
scanscanscans for available access points (only scans it, doesn’t display anything)
scan_displayscan_ddisplays the results of the last scan
list_networkslist_ndisplays a list of configured networks and their status (active or not, enabled or disabled)
select_networkselect_nselect a network among those defined to initiate a connection (ie select_network 0)
enable_networkenable_nmakes a configured network available for selection (ie enable_network 0)
disable_networkdisable_nmakes a configured network unavailable for selection (ie disable_network 0)
remove_networkremove_nremoves a network and its configuration from the list (ie remove_network 0)
add_networkadd_nadds a new network to the list. Its id will be created automatically
set_networkset_nshows 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_networkget_ndisplays the required parameter for the specified network. See next section for a list of parameters
save_configsave_csaves 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 สามารถดูรายละเอียดได้ดังตารางด้านล่าง

KeyDescriptionParameters
ssidAccess point namestring
id_strString identifying the networkstring
priorityConnection priority over other APsnumber (0 being the default low priority)
bssidMac address of the access pointmac address
scan_ssidEnable/disbale ssid scan0, 1, 2
key_mgmtType of key managementWPA-PSK, WPA_EAP, None
pairwisePairwise ciphers for WPACCMP, TKIP
group=TKIPGroup ciphers for WPACCMP, TKIP, WEP104, WEP40
pskPre-Shared Key (clear or encrypted)string
wep_key0WEP key (up to 4: wep_key[0123])string
eapExtensible Authentication ProtocolMD5, MSCHAPV2, OTP, GTC, TLS, PEAP, TTLS
identityEAP identity stringstring
passwordEAP passwordstring
ca_certPathname to CA certificate file/full/path/to/certificate
client_certPathname to client certificate/full/path/to/certificate (PEM/DER)
private_keyPathname 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 ครับ

EOF.← กลับไปอ่านบทความอื่น