# 检测brctl命令是否存在 brctl > /dev/null if [ $? != 1 ]; then echo Command brctl not exist, please setup it. The setup execute command is \"yum install bridge-utils\" exit 0 fi
# 检测网桥br0是否存在,如果存在首先删除 declare -i result=$(brctl show | grep eth0 | wc -l) if [ $result > 0 ]; then echo detect the bridge br0 have already exist, first delete it ifconfig br0 down brctl delbr br0 fi
ifconfig eth1 0.0.0.0 ifconfig eth2 0.0.0.0 brctl addbr br0 brctl addif br0 eth1 brctl addif br0 eth2 ifconfig br0 up echo create bridge br0 success, you can use command : \"brctl show\" to check
网桥删除脚本
本脚本将桥接网卡br0删除
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/bin/bash
# 检测是否存在网桥br0 declare -i result=$(brctl show | grep br0 | wc -l) if [ $result == 0 ]; then echo "bridge br0 not exists, exit immediately" exit 0 fi