1

There are two network settings in /etc/wpa_supplicant.conf. Both of them have the same ssid but with different id_str and psk.

After connecting to AP, how can I check which network configuration I am using?

ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
#Disable wifi direct
p2p_disabled=1

network={
    ssid="SameSSID"
    psk="12345678"
    id_str="CorrectPSK"
}

network={
    ssid="SameSSID"
    psk="00000000"
    id_str="WrongPSK"
}
1

In user space, wpa_supplicant can be controlled via wpa_cli.
The current information can be confirmed with the following command.

$ wpa_cli -p /var/run/wpa_supplicant status

The status information can be used to check various information of the currently connected AP.
I am sure you can judge this information.

Below is an example of use. The AP information used during the test is shown below.

ssid: test_ap
password: 12345678

Below is an example of using the command.
Perhaps psk will change according to your password.

root@test:~# wpa_cli -p /var/wpa status
Selected interface 'wlan0'
bssid=12:34:56:78:90:a1
ssid=test_ap
id=0
passphrase=12345678
psk=?????????????????????????????
mode=station
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
address=11:22:33:44:55:66
signal_level=-22
root@test:~#
0

If you want to find out which network you are connected to, you can also use the BSSID to identify it. It is typically the MAC address of the access point (notation: xx:xx:xx:xx:xx:xx). It depends on the system how to find the BSSID. ifconfig usually shows this information on BSDs and maybe other Unix systems.

You can also use the bssid parameter to further restrict the access point selection, so it is less confusing.

Example:

network={
    ssid="My network"
    bssid=00:11:22:33:44:55
    ...
}

One BSSID (one access point)

In case you have just forgot which configuration is the correct one (that means you have only one network/AP) comment one configuration block out (use #) and see, if the wpa supplicant still connects.

The first try would look like:

ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
#Disable wifi direct
p2p_disabled=1

network={
    ssid="SameSSID"
    psk="12345678"
    id_str="CorrectPSK"
}

#network={
#    ssid="SameSSID"
#    psk="00000000"
#    id_str="WrongPSK"
#}

Then restart wpa_supplicant and see if associates with the access point. If it does not it is the other configuration in the other network { } block that is the valid one.

  • Thanks for your help. My problem is if there is only one AP in my room, I have 2 network settings in wpa_supplicant.conf. one has correct psk and the other one doesn't. How can I know which network setting I am using after connecting to the AP? (Because there is only one AP and it means one MAC Addr) – user2861965 Oct 26 '18 at 1:26
  • I edited the answer. I hope it helps. – Martin Sugioarto Oct 26 '18 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.