日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

CentOS6 kvm添加网卡桥接口脚本

發布時間:2025/4/16 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CentOS6 kvm添加网卡桥接口脚本 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
腳本任務 1,判斷網卡配置文件名稱為eth*或者是em* ,如dell服務器網卡CentOS5為eth*,而CentOS6為em*。 2,存在幾個網卡就復制幾個原網卡配置文件做為橋配置文件,n的設置的數量是4,如果超過4網卡則設置更高值,原配置文件是DHCP的改為static,用.*匹配行是存在CentOS5和6參數有引號的問題。 3, 生成虛擬機橋借口br*并一一對應,如br0對應eth0,br1對應eth1等等,并重啟網絡。 ? ? #! /bin/sh mypath="/etc/sysconfig/network-scripts" for((n=0;n<=4;n++))doif [ -f "$mypath/ifcfg-eth$n" ]thensed -i "s/^ONBOOT.*/ONBOOT=yes/" $mypath/ifcfg-eth$nsed -i "s/^BOOTPROTO.*/BOOTPROTO=static/" $mypath/ifcfg-eth$ncp -a $mypath/ifcfg-eth$n $mypath/ifcfg-br$nsed -i "/^HWADDR.*/d" $mypath/ifcfg-br$nsed -i "s/^DEVICE.*/DEVICE=br"$n"/" $mypath/ifcfg-br$nsed -i "s/^TYPE.*/TYPE=Bridge/" $mypath/ifcfg-br$necho "BRIDGE=br$n">>$mypath/ifcfg-eth$necho "The device br$n<---->eth$n is add success !"elseecho "The device eth$n not exist!"fiif [ -f "$mypath/ifcfg-em$n" ]thensed -i "s/^ONBOOT.*/ONBOOT=yes/" $mypath/ifcfg-em$nsed -i "s/^BOOTPROTO.*/BOOTPROTO=static/" $mypath/ifcfg-em$ncp -a $mypath/ifcfg-em$n $mypath/ifcfg-br$nsed -i "/^HWADDR.*/d" $mypath/ifcfg-br$nsed -i "s/^DEVICE.*/DEVICE=br"$n"/" $mypath/ifcfg-br$nsed -i "s/^TYPE.*/TYPE=Bridge/" $mypath/ifcfg-br$necho "BRIDGE=br$n">>$mypath/ifcfg-em$necho "The device br$n<---->em$n is add success !"elseecho "The device em$n not exist!" fi done /etc/init.d/network restart

轉載于:https://blog.51cto.com/songxj/1070725

總結

以上是生活随笔為你收集整理的CentOS6 kvm添加网卡桥接口脚本的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。