shell-KVM网桥自动化配置
程序员文章站
2022-05-10 16:20:48
...
网桥配置
上一篇文章我给大家分享了自动化安装KVM的脚本,那么今天咱就接着来一手网桥配置.废话少B,代码如下:
#!bin/sh
#Author:学编程的鱼
#CDSN ID号:qq_46151595
#Creat Date :2020-02-11
#测试环境:Vmware 15
#版本号: Centos7_X86_64
#Script Description :Build network bridge.
#声明:本文为原创文章,遵循 CC 4.0 BY 版权协议,供所有人学习使用,转载请附上原文出处链接。
judge(){
a="`rpm -qa |grep bridge-utils|awk -F "-" '{print $1"-"$2}'`"
if [ $?=0 ]&&[ $a == "bridge-utils" ];
then
echo -e "\033[32mEnvironment test is Finish ! Script will be execute !\033[0m"
else
echo -e "\033[31mPlease check Bridge-utils-1.5-9.el7.x86-64 installed !\033[0m"
exit
fi
}
read3(){
FILE=(`ls -a /etc/sysconfig/network-scripts`)
echo -e "查找您的网络配置文件名并输入:\n${FILE[@]}"
}
start3(){
echo -e "Please Enter Network profile name\nFor Example: \033[36mifcfg-ens33\033[0m"
read -p ":" FILE_NAME
for a in ${FILE[@]}
do
if [ $a == $FILE_NAME ];then
echo -e "\033[32mWill write configure!\033[0m"
sleep 1
echo -e "BRIDGE=\"br0\"">>/etc/sysconfig/network-scripts/$FILE_NAME
echo -e "DEVICE=\"br0\"\nNM_CONTROLLED=\"yes\"\nONBOOT=\"yes\"\nTYPE=\"Bridge\"\nBOOTPROTO=\"dhcp\"">>/etc/sysconfig/network-scripts/ifcfg-br0
echo -e "\033[32mComplete !\033[0m"
exit
else
echo -e "\033[32mCheck the configure file don not close...\033[0m"
clear
continue
fi
done
}
clear
judge
read3
start3
systemctl restart network
~
~
~
~
~
"br0_config.sh" 42L, 1180C
下面来看一看执行效果:
最后如果使用过程中出现问题欢迎留言讨论.!
上一篇: [Azure]使用Powershell克隆ARM虚拟机(托管磁盘)
下一篇: KVM