1

I have a Raspberry Pi4 24h connected to the internet via Wifi. Sometimes, I think due some signal loss, it don't reconnect until I reboot it.

I've already tried to run a script that automatically monitor the wifi connection and run sudo systemctl restart networking.service but it didn't solve my issue.

So, is there any benefit if I install the NetworkManager on Rpi? Can it reconnect to wifi networks or another feature that can help?

I'm running Raspbian Buster.

2 Answers2

1

I have several Pi's that run 24/7 and they will automatically reconnect when the wifi is available (I deliberately have my wifi networks turn off at night when there is no need for them to be on). I have found the below to be 100% reliable. I am using static IP on my Pi's but it should work fine with DHCP as well:

sudo nano /usr/local/bin/checkwifi.sh

Enter this code to restart network (change 192.168.1.1 for an IP address that you expect to always be available, typically your internet router):

ping -c4 192.168.1.1 > /dev/null

if [ $? != 0 ] then echo "No network connection, restarting wlan0" /sbin/ifdown 'wlan0' sleep 5 /sbin/ifup --force 'wlan0' fi

You need schedule this to run regularly. I chose every five minutes:

crontab -e 

Add:

*/5 * * * * /usr/bin/sudo -H /usr/local/bin/checkwifi.sh >> /dev/null 2>&1
PeteC
  • 341
  • 1
  • 4
0

The default dhcpcd is reliable and will automatically connect if correctly configured. See How to set up networking/WiFi

Raspberry Pi OS DOES NOT use networking.service - unless you misconfigure it.

You can use NetworkManager, but it is difficult to configure manually, and the GUI networking tool in Raspbian won't work. It is no more reliable than dhcpcd. In addition it needs to be re-configured for each Pi - you can't simply swap SD Cards.

Milliways
  • 62,573
  • 32
  • 113
  • 225