Simple question:

How do I set my Raspberry Pi to only connect to my WiFi network if the Ethernet is disconnected?

So it should be something like:

  1. Booting up
  2. Checking if ethernet is connected
  3. Try for 30 seconds or so
  4. If no ethernet, try to connect to Wifi
  5. Try for 30 seconds
  6. if still no connection go back to 2.

Can I do that via crontab and a shell script?

I don't have a screen, keyboard or mouse attached to my RPi and it happened before that it refused to connect to any network. Maybe a priority conflict in the settings?

Running Raspberry Pi 3 Model B, on Rasbian Jessie, headless mode.



1 Answer 1


This sounds like a job for the NetworkManager (https://en.m.wikipedia.org/wiki/NetworkManager). It does handle activation and deactivation of "connections", such as wired and wireless ones. It prefers wired ones over wireless, and it is able to switch forth and back. But it's kind of a beast, be warned.

The Raspbian base installation comes without NetworkManager and only uses dhcpcd which can't do the things you are asking for. NetworkManager can be installed separately; it's widely used in desktop distributions, such as Ubuntu.

The NetworkManager consists of the daemon, with optional GUIs on top. There's also a CLI, nmcli, which should suit your headless operation.

  • Thanks for pointing me into the right direction. Still have some conflicts between ifplugd, wpa_supplicant and nmcli. But shouldn't be too complicated from here
    – Paul
    Jul 16, 2017 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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