Dietpi: General | Support multiple WiFi SSID's and auto connect to one during boot.

Created on 30 May 2016  ·  11Comments  ·  Source: MichaIng/DietPi

http://dietpi.com/phpbb/viewtopic.php?f=9&t=451#p1974

Considerations:

  • Allow for multiple wifi credentials in dietpi.txt
  • Create a script during boot that does a iw scan, match against our dietpi.txt list, then update /etc/network/interfaces with the required info. Finally connect.
  • Somehow integrate saving/loading wifi creds in dietpi-config
Feature Request

Most helpful comment

@Fourdee
Multiple entries in wpa_supplicant.conf are possible.

wpa_supplicant will automatically select the best network based on the order of network blocks in the configuration file, network security level (WPA/WPA2 is preferred), and signal strength.

👍

We could allow adding AUTO_SETUP_NET_WIFI2_SSID (WIFI3, ...) and related other entries to dietpi.txt and add all of them to wpa_supplicant.conf. However this strictly needs DHCP client to be used for WiFi interface, since we cannot configure different interfaces (within /etc/network/interfaces) to use the same wpa_supplicant.conf but different networks inside (all of the arrays have the same name).
But, hmm we could configure different interfaces to use different wpa_supplicant${i}.conf files actually 🤔, if this works with just one WiFi adapter? I am just not sure what happens if two SSIDs are available at the same time. Two interfaces trying to configure the same adapter? ...

Maybe going with a single interface for now is simpler/cleaner:

  • Allowing to add multiple WiFi SSIDs + credentials to dietpi.txt with ascending variable numbers.
  • We loop through available variables and add them as separate network={ entries to wpa_supplicant.conf.
  • We then rely on "wpa_supplicant will automatically select the best network based on the order of network blocks in the configuration file, network security level (WPA/WPA2 is preferred), and signal strength.": https://linux.die.net/man/5/wpa_supplicant.conf

To not allow messing up with dietpi-config, we need to change the WiFi adapter menu:

  • Add new menu entry to add an additional SSID with credentials. By default scan and select, otherwise allow manual setup as already handled now.
  • Add one as well for SSID removal, at least if it is not the last available configured SSID.
  • Perhaps show and allow to adjust really all entries (key-mgr, identity, cert, eap, ...), but pre-fill the fields with "auto" which in case we do not save to dietpi.txt/wpa_supplicant.conf then?
  • If multiple SSIDs are found, show a cascaded WiFi menu to select SSID first. Hide STATIC/DHCP switch then, instead force DHCP to avoid the need to separate interfaces.

As the overall entries are quite much and can be added/removed, perhaps it's better to allow additional SSIDs just within a separate dietpi-wifi.txt e.g.? This way we can also easier recognize if there are actually additional ones configures or not and show adapter config menu + DHCP force accordingly.

All 11 comments

I'll be very happy when this is made available :) Please? :)

must have feature ;)
here are nice snippets for scanning: http://stackoverflow.com/questions/17809912/parsing-iw-wlan0-scan-output

Wouldn't even need scanning, just failover. Connect first, if fail, connect second, etc. Though scanning would perform better, it's just an optimization.

Note to self:

  • Does wpa_supplicant.conf support multiple SSID entries and auto connect?

There should be some kind of file like dietpi.txt that will be used during boot to connect to any of the WiFis configured in that specific file. Not only during initial setup of the RasPi.

@Fourdee
Multiple entries in wpa_supplicant.conf are possible.

wpa_supplicant will automatically select the best network based on the order of network blocks in the configuration file, network security level (WPA/WPA2 is preferred), and signal strength.

👍

We could allow adding AUTO_SETUP_NET_WIFI2_SSID (WIFI3, ...) and related other entries to dietpi.txt and add all of them to wpa_supplicant.conf. However this strictly needs DHCP client to be used for WiFi interface, since we cannot configure different interfaces (within /etc/network/interfaces) to use the same wpa_supplicant.conf but different networks inside (all of the arrays have the same name).
But, hmm we could configure different interfaces to use different wpa_supplicant${i}.conf files actually 🤔, if this works with just one WiFi adapter? I am just not sure what happens if two SSIDs are available at the same time. Two interfaces trying to configure the same adapter? ...

Maybe going with a single interface for now is simpler/cleaner:

  • Allowing to add multiple WiFi SSIDs + credentials to dietpi.txt with ascending variable numbers.
  • We loop through available variables and add them as separate network={ entries to wpa_supplicant.conf.
  • We then rely on "wpa_supplicant will automatically select the best network based on the order of network blocks in the configuration file, network security level (WPA/WPA2 is preferred), and signal strength.": https://linux.die.net/man/5/wpa_supplicant.conf

To not allow messing up with dietpi-config, we need to change the WiFi adapter menu:

  • Add new menu entry to add an additional SSID with credentials. By default scan and select, otherwise allow manual setup as already handled now.
  • Add one as well for SSID removal, at least if it is not the last available configured SSID.
  • Perhaps show and allow to adjust really all entries (key-mgr, identity, cert, eap, ...), but pre-fill the fields with "auto" which in case we do not save to dietpi.txt/wpa_supplicant.conf then?
  • If multiple SSIDs are found, show a cascaded WiFi menu to select SSID first. Hide STATIC/DHCP switch then, instead force DHCP to avoid the need to separate interfaces.

As the overall entries are quite much and can be added/removed, perhaps it's better to allow additional SSIDs just within a separate dietpi-wifi.txt e.g.? This way we can also easier recognize if there are actually additional ones configures or not and show adapter config menu + DHCP force accordingly.

Notes:

  • 🈯️ PREP copy generated /var/lib/dietpi/dietpi-wifi.db to /boot/
  • 🈯️ Check/test automated WiFi setup
  • dietpi-config
    -- 🈯️ Added a warning/info for users | Disable multiple SSID's when static
    -- 🈯️ Option to remove existing entries in dietpi-config (set SSID='', clears after wificreds set)
    -- 🈯️ Support selecting KEYMGR?
    -- 🈯️ Test connection: WPA-PSK
    -- 🈯️ Test connection: WEP
    -- 🈯️ Test connection: None
  • 🈯️ Check Patch during v6.15 > v6.16 update with WiFi in use.
  • 🈯️ Test HotSpot in dietpi-config still works

How wpa_supplicant.conf deals with priority and ordering

-- Prefers to connect to a secured (WPA/WEP) SSID, regardless of lower signal strength against open SSID.
-- 🈯️ Aside from that, connects to the SSID with the greatest strength, regardless of its order in wpa_supplicant.conf

Note to self:

Optional (Wifi): section:

  • Does not require updating, until we update any image. Existing images will still use the older 1 SSID system.

Automated works, however, dietpi-config afterwards results in:

  • 🈯️ Because i'am running static!
    Needs tweaking
    image

Hotspot required entries:

# Wifi
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0
#gateway 192.168.0.1
wireless-power off
#dns-nameservers 8.8.8.8 8.8.4.4

# IP tables
up iptables-restore < /etc/iptables.ipv4.nat

🈯️ All testing passed https://github.com/Fourdee/DietPi/issues/368#issuecomment-421574150

The only thing I cannot achieve, due to lack of available hardware for setting up a test network, is:

  • Testing WPA-EAP with automated installation
  • Implement WPA-EAP options in dietpi-config

Completed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Invictaz picture Invictaz  ·  3Comments

bhaveshgohel picture bhaveshgohel  ·  3Comments

Kapot picture Kapot  ·  3Comments

Fourdee picture Fourdee  ·  3Comments

Invictaz picture Invictaz  ·  3Comments