• VMware中克隆虚拟机出现eth0改变为eth1情况


    解决如下:

    查看复制虚拟机网卡信息如下:

     1 root@jcfx-2 ~]# ifconfig
     2 eth1      Link encap:Ethernet  HWaddr 00:0C:29:CC:32:63  
     3           inet addr:192.168.72.11  Bcast:192.168.72.255  Mask:255.255.255.0
     4           inet6 addr: fe80::20c:29ff:fecc:3263/64 Scope:Link
     5           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
     6           RX packets:17551 errors:0 dropped:0 overruns:0 frame:0
     7           TX packets:166 errors:0 dropped:0 overruns:0 carrier:0
     8           collisions:0 txqueuelen:1000 
     9           RX bytes:1303129 (1.2 MiB)  TX bytes:63288 (61.8 KiB)
    10 lo        Link encap:Local Loopback  
    11           inet addr:127.0.0.1  Mask:255.0.0.0
    12           inet6 addr: ::1/128 Scope:Host
    13           UP LOOPBACK RUNNING  MTU:16436  Metric:1
    14           RX packets:8 errors:0 dropped:0 overruns:0 frame:0
    15           TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
    16           collisions:0 txqueuelen:0 
    17           RX bytes:584 (584.0 b)  TX bytes:584 (584.0 b)

    具体需求是将eth1修改为eth0:

    为什么eth0会变成eth1?

    Linux distribution使用udev动态管理设备文件,并根据设备的信息对其进行持久化命名。udev会在系统引导的过程中识别网卡,将mac地址和网卡名称对应起来记录在udev的规则脚本中。而对于新的虚拟机,VMware会自动为虚拟机的网卡生成MAC地址,当你克隆或者重装虚拟机软件时,由于你使用的是以前系统虚拟硬盘的信息,而该系统中已经有eth0的信息,对于这个新的网卡,udev会自动将其命名为eth1(累加的原则),所以在你的系统启动后,你使用ifconfig看到的网卡名为eth1;

    RedHat中,udev记录网络规则的脚本为:/etc/udev/rules.d/70-persistent-net.rules

    1 [root@jcfx-2 ~]# more /etc/udev/rules.d/70-persistent-net.rules 
    2 # This file was automatically generated by the /lib/udev/write_net_rules
    3 # program, run by the persistent-net-generator.rules rules file.
    4 # You can modify it, as long as you keep each rule on a single
    5 # line, and change only the value of the NAME= key.
    6 # PCI device 0x15ad:0x07b0 (vmxnet3)
    7 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a0:25:f7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
    8 # PCI device 0x15ad:0x07b0 (vmxnet3)
    9 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:cc:32:63", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
     1 解决如下:
     2 将70-persistent-net.rules脚本中多出来的eth1信息注销,并且修改原有的eth0的MAC地址信息,该信息与eth1的MAC信息保持一致,或者修改为别的MAC地址;
     3 修改如下:
     4 [root@jcfx-2 ~]# more /etc/udev/rules.d/70-persistent-net.rules 
     5 # This file was automatically generated by the /lib/udev/write_net_rules
     6 # program, run by the persistent-net-generator.rules rules file.
     7 # You can modify it, as long as you keep each rule on a single
     8 # line, and change only the value of the NAME= key.
     9 # PCI device 0x15ad:0x07b0 (vmxnet3)
    10 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:cc:32:63", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
    11 # PCI device 0x15ad:0x07b0 (vmxnet3)
    12 #SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:cc:32:63", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
    13 最后重启服务器:
    14 reboot
  • 相关阅读:
    转载:对不起,我是程序员
    [VB6]支持UTF文本文件访问的模块 支持UTF8无BOM格式编码自动识别
    Do it. Do it right. Do it right now!
    TortoiseGit密钥的配置
    GIT服务器配置
    Linux下的帧缓冲lcd应用编程及Framebuffer驱动程序模型
    Linux设备驱动程序学习(19)-USB 驱动程序(四)
    是什么浪费了我的上网时间?
    【转】处理wording的一些参考
    ElementUI学习之rules详解
  • 原文地址:https://www.cnblogs.com/qlwang/p/8018789.html
Copyright © 2020-2023  润新知