2

In my (development) situation, I have 2 WLANs:

1. local with hidden SSID and no internet access.
2. not-hidden, with internet access.

I sometimes need to switch between them. Switch 1->2 is relatively easy, select the WIFI Icon and select the network.

However, switch 2->1 is troublesome, the hidden WLAN can not be found using the WIFI Icon. And worse, the wpa_supplicant.conf file has the hidden SSID disabled* for me, so even a reboot doesn't work unless I manually fix the config file.

Is there an easy solution to this? (Or should I write some script that restores the wpa_supplicant.conf and restarts the service?)


PS.* with disabled, I mean in my wpa_supplicant.config:

disabled=1

And with hidden, that I had to say:

scan_ssid=1

Other information in the wpa_supplicant file is the sensitive part with passwords and network names.

As I say in my comments, I was looking for a more 'user friendly' way of executing 'wpa_cli enable 0 && wpa_cli reconnect 0'.

  • 1
    the wpa_supplicant.conf file has the hidden SSID disabled for me what do you mean? can you put your wpa_supplicant file content ? – Ephemeral Dec 19 '19 at 8:59
  • 2
    @Ephemeral, I added the requested information to the question: disabled=1 was set automatically. Actually, I think I can solve the issue now with 'wpa_cli enable 0 && wpa_cli reconnect 0', however, I was looking for a more visual/user friendly way that I could put in the service manual for other users to use. – Pieter21 Dec 19 '19 at 9:39
  • 1
    In this case you can create a bash script containing your wpa_cli commands and with passing argument at this script : $1 for example can be 'Local' or 'External' or another names as you want. Then in a terminal you can call for example sudo bash myscript.sh "Local" for switching to local network and sudo bash myscript.sh "External" for switching to the other network. – Ephemeral Dec 19 '19 at 20:10
2

If you use wpa_cli you can use for example this script for a more 'user friendly' way ?

#!/bin/bash
# switchnetwork.sh

LOCALNET=0
EXTERNALNET=1    

function switch_to_local_net(){
      echo "SWITCHING TO NETWORK ID $LOCALNET"
      wpa_cli enable $LOCALNET && wpa_cli reconnect $LOCALNET
}
function switch_to_external_net(){
      echo "SWITCHING TO NETWORK ID $EXTERNALNET"
      wpa_cli enable $EXTERNALNET && wpa_cli reconnect $EXTERNALNET
}

case $1 in
     LOCAL|local) switch_to_local_net ; exit 0;;
     EXTERNAL|external) switch_to_external_net ; exit 0;;
     *) echo "Sorry arguments are: LOCAL or EXTERNAL";;
esac

exit 1

Now you can use this script in a terminal like this:

sudo bash switchnetwork.sh LOCAL

or

sudo bash switchnetwork.sh EXTERNAL

You can also put the bash script into /usr/bin/ directory (or other directory present in your $PATH environment variable) to can call switchnetwork without the script path.

| improve this answer | |
2

I don't know how to show a hidden WLAN network with the WiFi Icon. I think it's by definition not to show it. But another main problem seems to be that wpa_supplicant modifies its configuration in /etc/wpa_supplicant/wpa_supplicant.conf. By default it has an option update_config=1 set that exactly allows modification and to disable a network section with option disabled=1. You can avoid modifications by just setting update_config=0. Then wpa_supplicant will never modify its configuration.

| improve this answer | |
  • Thanks, I will definitely put the update_config=0 back in my config. Indeed I did not expect the hidden SSID to show, but at least an option to connect to an unidentified network (just like Windows). (I will accept the other answer though, since the wpa_cli will do the actual switching) – Pieter21 Dec 21 '19 at 8:49

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.