Skip to content

Instantly share code, notes, and snippets.

@xk
Last active January 13, 2017 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xk/73e4447d16b4fbd2d58e50cb909f85bd to your computer and use it in GitHub Desktop.
Save xk/73e4447d16b4fbd2d58e50cb909f85bd to your computer and use it in GitHub Desktop.
WIFI AUTO RECONNECT
#!/bin/bash
# The IP for the server you wish to ping
SERVER=192.168.100.1
sleep 30s
while [ 1 ]; do
# Only send two pings, sending output to /dev/null
ping -c2 ${SERVER} > /dev/null
# If the return code from ping ($?) is not 0 (meaning there was an error)
if [ $? != 0 ]
then
# Restart the wireless interface
ifdown --force wlan0
ifup wlan0
fi
sleep 1m
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment