2020/12/05

Script to reconnect wan via rc.inet1

My router is a Linux PC with 2 lan boards, one for local lan and the other directly connected to the ISP router (configured as bridge). Each time my ISP disconnects me for whatever reason I had to either reboot the computer or keep running rc.inet1 restart until the connection is made.

So, even if it doesn't happen often, at one point I got bored of it and decided to write an script to force the reconnection as soon as possible:

 #!/bin/bash
while true ; do
   clear
   ./rc.inet1 restart
   ping google.com -c 1
   if [ $? == 0 ]; then
      exit
   fi;
   sleep 30
done