当前位置: 主页 > shell编程 >

shell脚本解决克隆vmware后有网卡冲突的问题

时间:2015-04-23 01:24来源:cnhzz.com 作者:菜鸟HOW站长 举报 点击:

克隆vmware后有网卡冲突的问题,每次建多个实验虚拟机的时候都是很重复的事情。因此,有下面的脚本可以快速搞定实验环境的搭建。

克隆后,登陆主机,新建一个net.sh粘贴下面的脚本,然后赋予执行权限(chmod +x)然后运行./net.sh 就可以搞定。

#!/bin/bash
sed -i 's/eth0/eth2/g' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i 's/eth1/eth3/g' /etc/sysconfig/network-scripts/ifcfg-eth1
sed -i '/HWADDR/d' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '/HWADDR/d' /etc/sysconfig/network-scripts/ifcfg-eth1
ifconfig eth2 | sed -n '1p' | cut -b 32- >> /etc/sysconfig/network-scripts/ifcfg-eth0
ifconfig eth3 | sed -n '1p' | cut -b 32- >> /etc/sysconfig/network-scripts/ifcfg-eth1
sed -i 's/HWaddr /HWaddr=/g' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i 's/HWaddr /HWaddr=/g' /etc/sysconfig/network-scripts/ifcfg-eth1
mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth2
mv /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth3

别忘记重启网卡

service network restart
------分隔线----------------------------
发表评论
为了和诣的生活,我关闭了评论页面,请大家到QQ群里交流吧:348944156,也欢迎关注本站微信公众号:centoscn
栏目分类