0

On multiple RPis I have the same issue - once I have a /etc/wpa_supplicant/wpa_supplicant.conf with a single network configured, using wpa_cli to add a network does not update the configuration file after using save_config - this return OK there is no failure?

When changing properties of the existing network (0) followed by save_config then wpa_supplicant.conf is modified with those changed. However, the second network is not added.

For reference, here is the configuration:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={
        ssid="NetworkSSID"
        psk=xxxxxxxxxxxx
}

Then issuing the following series of wpa_cli actions:

$ wpa_cli

wpa_cli v2.8-devel
Copyright (c) 2004-2019, Jouni Malinen <j@w1.fi> and contributors

This software may be distributed under the terms of the BSD license.
See README for more details.


Selected interface 'p2p-dev-wlan0'

Interactive mode

> add_network 
1
> set_network 1 ssid "MyNewNetwork"
OK
> set_network 1 password "xxxxxxxxxx"
OK
> enable_network 1
OK

## Adding this for demonstration

> set_network 0 priority 10
OK

## end of demo

> save_config 
OK
> quit

The modified wpa_supplicant.conf is now...

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={
        ssid="NetworkSSID"
        psk=xxxxxxxxxxxx
        priority=10
}

The configuration was clearly updated, but the new network (1) is not added.

I'm building some configuration tooling, so using dbus to communicate with wpa_supplicant (indirectly). It's the same there as using the interactive CLI. What am I missing?

This is all being done as root, and root (and pi) are part of the netdev group. The configuration is being updated, just a new network is not being persisted in the wpa_supplicant.conf so not persisted on reboot.

  • What OS? What are you attempting to achieve? – Milliways Dec 10 '19 at 23:19
2

I encountered the same error here is how it worked for me:

Remove your network conf in /etc/wpa_supplicant/wpa_supplicant.conf, it must look like this :

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

Ensure you have no instance of wpa_supplicant and start wpa_supplicant:

sudo killall wpa_supplicant
sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

Remove all registered networks with wpa_cli:

~$ sudo wpa_cli
> remove_network 0
OK
> remove_network 1
OK 
> remove_network 2
OK
> remove_network X
FAIL

When the remove_network command return FAIL, you have no registered network, then :

> add_network
0
> set_network 0 ssid "wifi1"
OK
> set_network 0 psk "PASSWORD"
OK
> add_network
1 
> set_network 1 ssid "wifi2"
OK
> set_network 1 psk "PASSWORD"
OK
> save_config
> quit

Now you have two networks in your wpa_supplicant.conf

| improve this answer | |
  • 1
    I happened on the same solution, by accidentally (not sure how) saving a configuration with no networks. It started working after that too. – pryomoax Dec 11 '19 at 23:37

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.