#!/bin/bash
# put his script at /usr/local/bin/check_network
# then set execution permissions: chmod +x /usr/local/bin/check_network
# verifies network connection, if it fails then try to restart:
ROUTER_IP=<your router ip address>
( ! ping -c1 $ROUTER_IP >/dev/null 2>&1 ) && service network restart >/dev/null 2>&1
# at /etc/crontab add this:
# run script every two minutes
*/2 * * * * root /usr/local/bin/check_network
I was doing some works on a very old debian server (6.0 squeese), and got many troubles on restarting network interfaces. I tried using "/etc/init.d/networking restart", but it always failed to reconnect.
The only way to do networking reset was restarting the server.
I found that changing network definition without restarting server ensures reconnection. That's why I got this very simple script and crontab item
The only way to do networking reset was restarting the server.
I found that changing network definition without restarting server ensures reconnection. That's why I got this very simple script and crontab item
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.