当linuxxuniji/ target=_blank class=infotextkey>linux虚拟机的网卡不能识别时,可以考虑使用以下的shell/ target=_blank class=infotextkey>shell脚本尝试解决。
linux脚本内容:
vi network-issue-fix.sh
#!/bin/bash
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
执行:
执行脚本后,系统重启,问题解决。
以上脚本中的网卡为eth0,请根据实际情况自行修改。