• 解决拷贝的虚拟机网卡配置不正确的问题


    解决拷贝的虚拟机网卡配置不正确的问题

            一、背景

            在开发的过程中,我们经常会拷贝虚拟机。有时候我们拷贝来的虚拟机的网卡不能正常启动。出现“没有找到合适的设备:没有找到可拥有链接System eth0的设备”。

            二、解决问题

            我的虚拟机的网络适配器的网络连接模式是桥接模式。

            a、清空 /etc/udev/rules.d/70-persistent-net.rules 文件。

            b、重启机器。(可使用reboot命令重启机器)。重启后的系统里的 /etc/udev/rules.d/70-persistent-net.rules会生成新的网卡MAC地址等网卡信息。

            c、配置网卡文件ifcfg-eth(0-n)。如果有多个网卡,系统/etc/sysconfig/network-scripts路径下有多个以ifcfg-eth开头的文件。我们系统就一个网卡,所以配置ifcfg-eth0文件即可。配置信息如下:

             70-persistent-net.rules信息如下:

            [root@localhost ~]# cat /etc/udev/rules.d/70-persistent-net.rules

    # This file was automatically generated by the /lib/udev/write_net_rules      
    # program, run by the persistent-net-generator.rules rules file.        
    # You can modify it, as long as you keep each rule on a single

    # line, and change only the value of the NAME= key.
    # PCI device 0x8086:0x100f (e1000)
    # PCI device 0x8086:0x100f (e1000)
    # PCI device 0x8086:0x100f (e1000)

    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:65:ce:1f", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

    ifcfg-eth0的信息如下:

    DEVICE=eth0
    BOOTPROTO=none
    HWADDR=00:0c:29:65:ce:1f
    ONBOOT=yes
    NETMASK=255.255.255.0
    IPADDR=192.168.1.120
    GATEWAY=192.168.1.1
    TYPE=Ethernet

    说明:把70-persistent-net.rules 文件中ATTR{address} 和 ifcfg-eth0中的HWADDR的值配置成一样,70-persistent-net.rules文件中的NAME和ifcfg-eth0的DEVICE的值配置成一样。最后重启机器就可以了。

  • 相关阅读:
    例5-6
    例5-5
    例5-4
    例4-5
    例4-4
    例4-3
    例4-2
    例3-11
    例3-10
    例3-9
  • 原文地址:https://www.cnblogs.com/fiberhome/p/7942935.html
Copyright © 2020-2023  润新知