日常工作問題解決:使用vmvare克隆centos6虛擬機造成無eth0的解決辦法


一、問題描述

樣本虛擬機配置有兩張網卡,eth0、eth1,使用vmvare克隆虛擬機后,復制的虛擬機,沒有網卡eth0,eth1,而是有eth2、eth3,如下所示:

二、原因分析

復制系統中網卡的mac地址已經變了,但是/etc/udev/rules.d/70-persistent-net.rules中仍然保留了老網卡的信息,新網卡則會從eht1網上增加,被識別為eth2,eth3

三、解決辦法:

概括步驟:

1.檢查並修改 /etc/udev/rules.d/70-persistent-net.rules 文件中網卡名並重啟系統

2.modprobe -r e1000 卸載網卡模塊

3.modprobe e1000 重新加載網卡模塊

4.修改/etc/sysconfig/network-scrcipts中網卡的配置文件(使其格式為ifcfg-網卡名)

5.重啟網卡服務service network restart

具體步驟如下:

1、檢查並修改 /etc/udev/rules.d/70-persistent-net.rules 文件中網卡名

刪除原來錯誤的eth0和eth1配置信息,並修改NAME="eth2" 為 NAME="eth0",NAME="eth3"為NAME="eth1",如下所示


[root@localhost Desktop]# vim /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)

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

PCI device 0x8086:0x100f (e1000)

SUBSYSTEM"net", ACTION"add", DRIVERS"?*", ATTR{address}"00:0c:29:b5:69:06", ATTR{type}"1", KERNEL"eth*", NAME="eth1"

reboot重啟系統,使配置文件生效

2、modprobe -r e1000卸載網卡模塊

[root@localhost Desktop]# modprobe -r e1000

3、modprobe e1000重新加載網卡模塊

[root@localhost Desktop]# modprobe e1000

4、修改/etc/sysconfig/network-scrcipts中網卡的配置文件

修改eth0、eth1配置文件與70-persistent-net.rules中的mac地址相對應:

[root@localhost Desktop]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0c:29:b5:69:fc #修改為正確的mac地址
TYPE=Ethernet
UUID=9dcce425-39a0-477e-afa2-bf1a2d5615af
ONBOOT=yes # 修改為開機啟動
NM_CONTROLLED=yes
BOOTPROTO=dhcp

[root@localhost Desktop]# vim /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
HWADDR=00:0c:29:b5:69:06
TYPE=Ethernet
UUID=99037241-ffe5-4de7-8ca0-64ae19f30bd5
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp

5、重啟網絡服務


[root@localhost Desktop]# service network restart # 重啟網絡服務
Shutting down interface eth0:                              [  OK  ]
Shutting down interface eth1:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/9
state: activated
Connection activated
                                                           [  OK  ]

查看網絡信息


[root@localhost Desktop]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0C:29:B5:69:FC  
          inet addr:192.168.57.129  Bcast:192.168.57.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feb5:69fc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:272 errors:0 dropped:0 overruns:0 frame:0
          TX packets:178 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:17170 (16.7 KiB)  TX bytes:14884 (14.5 KiB)

eth1 Link encap:Ethernet HWaddr 00:0C:29:B5:69:06
inet6 addr: fe80::20c:29ff:feb5:6906/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:54 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:17700 (17.2 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:960 (960.0 b) TX bytes:960 (960.0 b)

發現修改成功,完畢


END
2019-10-23 00:01:32


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM