Raspberry, restart network, or reboot, at ping failure

Using a Raspberry Pi Zero (RPi), with wifi, I sometimes have problem that the WiFi connection is lost . This is due to that, at our boat, we are using the Teltonika RUT 240 router. The router just have one receiver/transmitter, LAN and WAN WiFi are shared, and in some use cases the WiFi will temporarily be disconnected. To restart the WiFi quick the following solution is used. This post will cover a solution, a bash script, with inspiration from this blogpost , but with some fine tuning. 😉 Another way could be using the watchdog function, described here , with reboot.