Wpa_supplicant Wireless Network Configuration

Source: Internet
Author: User
 

Currently, you can use wireless-tools or wpa_supplicant to configure the wireless network. Remember that the configuration of the wireless network is global, not for specific interfaces.

 

Wpa_supplicant is a good choice, but its disadvantage is that it does not support all drivers. Go to the wpa_supplicant website to obtain the list of supported drivers. In addition, wpa_supplicant can only connect to wireless networks with Essid configured. Wireless-tools supports almost all wireless NICs and drivers, but it cannot connect to those APs that only support WPA.

The compiled wpa_supplicant source code shows two main executable tools: wpa_supplicant and wpa_cli. Wpa_supplicant is the core program, and its relationship with wpa_cli is the relationship between the service and the client: wpa_supplicant is run in the background, and wpa_cli is used to search, set, and connect to the network.

How can I use wpa_supplicant to enable a Wi-Fi connection?

Step by step:

1. Run the wpa_supplicant program;

 

Run:/system/bin/wpa_supplicant-D-dwext-iwlan0-C/data/MISC/WiFi/wpa_supplicant.conf

Where:

-D: Add debugging information

-Dwext: wext, driver name

-Iwlan0: wlan0, Network Interface Name

/System/bin/wpa_supplicant: wpa_supplicant executable program path

/Data/MISC/WiFi/wpa_supplicant.conf: Path of the configuration file wpa_supplicant

2. Run the command line tool wpa_cli;

Run: wpa_cli-iwlan0-P/data/system/wpa_supplicant

Note: wpa_supplicant in-P/data/system/wpa_supplicant is not an executable program, but a control socket.

The interactive mode is displayed. The interactive mode commands are as follows:

 

 

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_result

Scan_r

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


 

Set the basic network format: set_network <network ID> <key> <parameter> [<parameter>]

Basic Format for displaying network information: get_network <network ID> <key>

The following table lists the corresponding parameters:

 

 

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)

 

 

Eg.1 connect to unencrypted AP

> Add_network (it will display a network ID for you, assume it returns 0)

> Set_network 0 SSID "666"

> Set_network 0 key_mgmt none

> Enable_network 0

> Quit

Eg.2 connect to the WEP encrypted AP

> Add_network (assume return 1)

> Set_network 1 SSID "666"

> Set_network 1 key_mgmt none

> Set_network 1 wep_key0 "your AP password"

> Enable_network 1

Eg.3, connect WPA-PSK/WPA2-PSK encrypted AP

> Add_network (assume return 2)

> Set_network 2 SSID "666"

> Set_network 2 PSK "your pre-shared key"

> Enable_network 2

At this point, the WiFi module can connect to the AP.

3. Use the command line tool wpa_cli to connect to the Wi-Fi network. Of course, you can also use the wpa_supplicant configuration file to connect.

Review the Command executed when running wpa_supplicant:

/System/bin/wpa_supplicant-D-dwext-iwlan0-C/data/MISC/WiFi/wpa_supplicant.conf

We added-C/data/MISC/WiFi/wpa_supplicant.conf during execution. We can write the settings of the AP we want to connect to in a certain format into the wpa_supplicant.conf configuration file.

Eg.

Ctrl_interface = dir =/data/system/wpa_supplicant group = system update_config = 1

Network = {

SSID = "my access point"

PROTO = WPA

Key_mgmt = WPA-PSK

PSK = "you pass words"

}

Wpa_supplicant Wireless Network Configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.