Connection test script

This is very simple bash script for connection test. Sometimes we need do networking restart if dhcpd server is broken or there is some link problems.

One day I need to know if I allow port 8080 in my firewall and I just type “iptables -n -F INPUT | grep 8080” instead of “iptables -n -L INPUT | grep 8080“. This mistake cut off my machine.

This script check connection to the gw and if the connection is break down it restart firewall and networking. If there is no connection on next check it restart networking and firewall afret 5 minutes.

Implementation
put into root’s crontab:
* * * * * /path/to/check-conn.sh

or as root type:
echo”* * * * * root /path/to/check-conn.sh” > /etc/cron.d/check-conn
chmod 755 /etc/cron.d/check-conn

One Response to “Connection test script”

  1. admin Says:

Leave a Reply