#!/bin/bash
#edit by xiaokong 2009-03-25#
#################functions#######################
function show(){
stat=$(iptables -vnL|grep -i accept|grep \/24|awk '{print $9}'|grep -v \/0|awk -F"/" '{print $1}'|awk -F"." '{print $3}')
for w in $stat
do
case $w in
0) echo
echo "192.168.0.0/14 network is online"
echo
;;
2) echo "network 192.168.2.0/24 is online"
echo
;;
105) echo "D305 is online"
;;
106) echo "D306 is online"
echo
;;
107) echo "D307 is online"
;;
108) echo "D308 is online"
;;
109) echo "D309 is online"
;;
110) echo "D310 is online"
;;
*) echo "There on room online"
;;
esac
done
}
function down(){
_IPS=$1
echo "downing $1 >>>>>>>>>"
iptables -D FORWARD -i eth0 -s $_IPS -j ACCEPT
iptables -D FORWARD -i eth1 -d $_IPS -j ACCEPT
}
function up(){
_IPS=$1
echo "uping $1 >>>>>>>>>>>"
iptables -A FORWARD -i eth0 -s $_IPS -j ACCEPT
iptables -A FORWARD -i eth1 -d $_IPS -j ACCEPT
}
#################functions end###################
jifang=$1
zt=$2
#echo "the parameter $#"
if [ $# -ne 2 ];then
if [ $1 = "show" ];then
show
else
echo "please type in this format: "
echo "control 305 up "
fi
elif [ $2 = "up" ];then
case $1 in
D305|d305|305) echo "d305's network is uping.....>>>>"
ips=172.16.105.0/24
up $ips
;;
D306|d306|306) echo "d306's network is uping.....>>>>"
ips=172.16.106.0/24
up $ips
;;
D307|d307|307) echo "d307's network is uping.....>>>>"
ips=172.16.107.0/24
up $ips
;;
D308|d308|308) echo "d308's network is uping.....>>>>"
ips=172.16.108.0/24
up $ips
;;
*) echo "wrong class room you have input!!!!!"
;;
esac
elif [ $2 = "down" ];then
case $1 in
D305|d305|305) echo "d305's network is dying.....>>>>"
ips=172.16.105.0/24
down $ips
;;
D306|d306|306) echo "d306's network is dying.....>>>>"
ips=172.16.106.0/24
down $ips
;;
D307|d307|307) echo "d307's network is downing.....>>>>"
ips=172.16.107.0/24
down $ips
;;
D308|d308|308) echo "d308's network is downing.....>>>>"
ips=172.16.108.0/24
down $ips
;;
*) echo "wrong class room you have input!!!!!!!"
;;
esac
fi
阅读(1215) | 评论(0) | 转发(0) |