shell脚本解决虚拟机网卡不识别
根据上一篇文章解决Device does not seem to be present,今天在网上突然发现已经有人写了个shell脚本来解决这个问题了,现在共享给大家.
脚本内容:
vi network-issue-fix.sh
然后执行
chmod +x network-issue-fix.sh
./network-issue-fix.sh
执行脚本后会重启,重启之后问题就解决了.当然如果你的网卡不是eth0,那就要自己修改下上面的脚本了.
ps:http://heylinux.com/archives/2416.html
脚本内容:
vi network-issue-fix.sh
echo "Updating 70-persistent-net.rules with eth0..." sed -i '7,9d' /etc/udev/rules.d/70-persistent-net.rules sed -i s/eth1/eth0/g /etc/udev/rules.d/70-persistent-net.rules echo "Updating ifcfg-eth0 with new MAC address..." newmac=`ip a | tail -n 1 | awk '{print $2}'` oldmac=`grep HWADDR /etc/sysconfig/networking/devices/ifcfg-eth0 | awk -F "=" '{print $2}'` sed -i s/$oldmac/$newmac/g /etc/sysconfig/networking/devices/ifcfg-eth0 cp /etc/sysconfig/networking/devices/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0 echo "Rebooting the OS" sleep 2 reboot
然后执行
chmod +x network-issue-fix.sh
./network-issue-fix.sh
执行脚本后会重启,重启之后问题就解决了.当然如果你的网卡不是eth0,那就要自己修改下上面的脚本了.
ps:http://heylinux.com/archives/2416.html
评论: