Chinaunix首页 | 论坛 | 博客
  • 博客访问: 311715
  • 博文数量: 43
  • 博客积分: 1590
  • 博客等级: 上尉
  • 技术积分: 508
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-22 22:16
个人简介

温柔的IT民工~

文章分类

全部博文(43)

文章存档

2013年(1)

2012年(2)

2011年(2)

2010年(7)

2009年(8)

2008年(15)

2007年(8)

分类:

2009-04-11 15:11:47

#!/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) |
0

上一篇:ngrep 的安装

下一篇:dhcp根据主机名分配ip

给主人留下些什么吧!~~