日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CentOS6 kvm添加网卡桥接口脚本

發布時間:2025/4/16 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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添加网卡桥接口脚本的全部內容,希望文章能夠幫你解決所遇到的問題。

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