I am looking for an elegant way to implement fallback behavior for the onboard Wifi. I want the raspberry pi to set up its own ad-hoc AP when it is not able to connect to an existing network.

For now, I intend to have it make this decision on boot (so that if i lose a connection to a network and I want it to start up in ad hoc mode I would reboot), so in my rc.local I determine if hostname -I produces anything, if not I want to configure ad hoc mode.

here is an example of instructions for doing just that, but I am hoping to find out if there is a way that I can do it without changing the file and saving it, because if I change the system configuration then it will stay as that upon reboot. I want it to revert back to original wpa_supplicant behavior upon reboot always and only set wlan0 up as ad-hoc when wpa_supplicant cannot connect to a network during boot.

So far the only thing I can think of is to change /etc/network/interfaces to ad-hoc config, restart networking, and then change /etc/network/interfaces back. This way there is only a small race condition during which a reboot would have the system stuck in ad-hoc mode during boot.

  • You may want to use the NetworkManager (comes with a CLI, too) instead of ifup. It's meant for this purpose.
    – Janka
    Jan 22, 2018 at 20:36
  • this is all about doing it headless and automated, though
    – Steven Lu
    Jan 23, 2018 at 16:13
  • And? As said, the NetworkManager has a command line interface (CLI) which can be used both to automate switching between preconfigured connections and to create/delete configurations. Look up nmcli.
    – Janka
    Jan 23, 2018 at 18:06
  • Oh! Sorry I missed that! Will take a look. Thank you!
    – Steven Lu
    Jan 23, 2018 at 21:38


Your Answer

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

Browse other questions tagged or ask your own question.