Skip to content

Instantly share code, notes, and snippets.

@TalalMash
Last active April 29, 2022 09:30
Show Gist options
  • Save TalalMash/1fdb6363b46575d05530c6f6546554a8 to your computer and use it in GitHub Desktop.
Save TalalMash/1fdb6363b46575d05530c6f6546554a8 to your computer and use it in GitHub Desktop.
[OpenWRT] Auto-reboot bad ISP modems on PPP down (Broadcom)
#!/bin/sh
#Add this file to /root
#For interactive adjustments and keyboard input, install screen "opkg update && opkg install screen"
#and add to rc.local before exit 0: "screen -d -m sh -c "sh /root/adsl.sh" &"
#Enable telnet/port-23 in modem settings, usually open by most bad ISPs
#Replace <> fields with your settings
while :
do
sleep 120 #Increase if your modem takes more than 2 minutes to provide internet connectivity from restart.
if [ "$(ping -q -c5 8.8.8.8 &>/dev/null && echo 0 || echo 1)" = "1" ]; then #Add -I <your wan> after -q for multi-wan setup
echo "Restarting modem"
(
sleep 2
echo '<username>'
sleep 1
echo '<password>'
sleep 2
echo 'sh'
sleep 1
echo 'reboot'
sleep 1
) | nc <your modem IP> 23 &
sleep 15
killall nc
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment