Skip to content

Instantly share code, notes, and snippets.

@WaterSibilantFalling
Created September 21, 2017 12:37
Show Gist options
  • Save WaterSibilantFalling/b031fc4ab0e87c3439ca23616d013d0a to your computer and use it in GitHub Desktop.
Save WaterSibilantFalling/b031fc4ab0e87c3439ca23616d013d0a to your computer and use it in GitHub Desktop.
a little script that keeps a particular interface's internet connection up. Every minute it tests the interface and re-raises the intenet connection if the interface is down
#!/bin/bash
# test the interface every X seconds, re-up it if it is down.
# Completely bugged: only tests that *a* or **any** interface is up
PING_TRY_ADDRESS="192.168.0.1"
INTER_TEST_SECS=60
INTERFACE=$1
while (( 1 == 1));
do
ping $PING_TRY_ADDRESS -w 1 >& /dev/null
rtn=$?
if (( $rtn != 0 ))
then
ifup $INTERFACE
fi
sleep $INTER_TEST_SECS
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment