3

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.

Thanks

Paul
  • 133
  • 4

1 Answers1

3

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.

TheDiveO
  • 1,591
  • 1
  • 11
  • 16
  • 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 '17 at 13:32