Skip to content

Instantly share code, notes, and snippets.

@hermes-pimentel
Last active May 2, 2016 17:02
Show Gist options
  • Save hermes-pimentel/5269ce41bf57915d87f8ad4c14fc60c3 to your computer and use it in GitHub Desktop.
Save hermes-pimentel/5269ce41bf57915d87f8ad4c14fc60c3 to your computer and use it in GitHub Desktop.
dd-wrt reset wan IP if internet isn't working
#!/bin/bash
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo `date` " - Internet OK - IP:" `ifconfig vlan2 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'` >> /tmp/script.out
exit 0
else
echo `date` " - Internet NOK - IP:" `ifconfig vlan2 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'` >> /tmp/script.out
killall -SIGUSR1 udhcpc
killall -SIGUSR2 udhcpc
sleep 600
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment