Useful Scripts
Jump to navigation
Jump to search
Script to check a file with hosts in that file. We will be using the ping command, if we can't ping the host we can do some magic;
Lets say the file guardfile.txt contains 1.1.1.1
#!/bin/sh cat /usr/home/anexit/guard/guardfile.txt | while read line do if [ ! -z $line ]; then PINGCOUNT=2 PING=$(ping -c $PINGCOUNT $line | grep received | cut -d ',' -f2 | cut -d ' ' -f2) if [ $PING -eq 0 ]; then echo "Attempting to establish connection..: $line" sh /etc/netstart sh /etc/rc.local else echo "Connection is live.: $line" fi fi done
This script was used as a con job when using the an ssh tunnel. SSH supports tunnels but when they crash there is no mechanism at the time of this writing to keep or bring interfaces back online. Man SSH and look for;
SSH-BASED VIRTUAL PRIVATE NETWORKS