[mdlug] efficient networking script?
mat.enders at gmail.com
mat.enders at gmail.com
Wed Apr 6 12:52:48 EDT 2011
Tony,
I think it is fairly efficient. I do a similar thing with the network shares at school. I run 15 cron jobs every minute of everyday to run a chgrp command recursively on the different shares so the files get the correct groups so they are readable and writable by the appropriate groups.
Sent on the Sprint® Now Network from my BlackBerry®
-----Original Message-----
From: Tony Bemus <tony at bemushosting.com>
Sender: mdlug-bounces at mdlug.org
Date: Wed, 06 Apr 2011 12:35:16
To: <mdlug at mdlug.org>; <discuss at mug.org>
Reply-To: MDLUG's Main discussion list <mdlug at mdlug.org>
Subject: [mdlug] efficient networking script?
Hello all,
I just loaded an old laptop with a firewall distro called IP Fire
(http://www.ipfire.org/), it is based on IP Cop. I have set it up with
a green+red config. The red interface is a USB NIC(phone) and the green
is the built in NIC. When I unplug the USB NIC it looses the red
interface, as expected. then later I plug in the USB NIC and the red
interface is there but doesn't configure the static ip. If I run
"./etc/init.d/network restart" then the red interface get the static IP.
I wrote a script that checks if the interface is there and if there is
an IP address. If there is no interface it does nothing, if there is
an interface and a IP address it does nothing. but if there is an
interface and NO IP address then it restarts the network.
This allows my wife and I to just plug in the USB NIC (phone) and wait a
minute and then the Internet starts working, no commands to run.
My question: Is this an efficient way to do this?
I have fcron running the script every minuet.
#!/bin/bash
red=`ifconfig | grep red0 | wc -l`
if [ "${red}" -gt "0" ]; then
echo "Red Interface Exists";
ip=`ifconfig | grep 192.168.1.2 | wc -l`
if [ "${ip}" -gt "0" ]; then
echo "IP address Exists";
else
echo "Restarting network";
sh /etc/init.d/network restart
fi
else
echo "No Red Interface";
fi
Tony Bemus
_______________________________________________
mdlug mailing list
mdlug at mdlug.org
http://mdlug.org/mailman/listinfo/mdlug
More information about the mdlug
mailing list